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

The following examples show how to use sun.tools.java.Type#isType() . 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 dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 2
Source File: RMIGenerator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 3
Source File: RMIGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 4
Source File: RMIGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 5
Source File: RMIGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 6
Source File: RMIGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 7
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 8
Source File: RMIGenerator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 9
Source File: RMIGenerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 10
Source File: RMIGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 11
Source File: RMIGenerator.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 12
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}
 
Example 13
Source File: RMIGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write the case block for the skeleton's dispatch method for
 * the remote method with the given "opnum".
 */
private void writeSkeletonDispatchCase(IndentingWriter p, int opnum)
    throws IOException
{
    RemoteClass.Method method = remoteMethods[opnum];
    Identifier methodName = method.getName();
    Type methodType = method.getType();
    Type paramTypes[] = methodType.getArgumentTypes();
    String paramNames[] = nameParameters(paramTypes);
    Type returnType = methodType.getReturnType();

    p.pOlnI("case " + opnum + ": // " +
        methodType.typeString(methodName.toString(), true, false));
    /*
     * Use nested block statement inside case to provide an independent
     * namespace for local variables used to unmarshal parameters for
     * this remote method.
     */
    p.pOlnI("{");

    if (paramTypes.length > 0) {
        /*
         * Declare local variables to hold arguments.
         */
        for (int i = 0; i < paramTypes.length; i++) {
            p.pln(paramTypes[i] + " " + paramNames[i] + ";");
        }

        /*
         * Unmarshal arguments from call stream.
         */
        p.plnI("try {");
        p.pln("java.io.ObjectInput in = call.getInputStream();");
        boolean objectsRead = writeUnmarshalArguments(p, "in",
            paramTypes, paramNames);
        p.pOlnI("} catch (java.io.IOException e) {");
        p.pln("throw new " + idUnmarshalException +
            "(\"error unmarshalling arguments\", e);");
        /*
         * If any only if readObject has been invoked, we must catch
         * ClassNotFoundException as well as IOException.
         */
        if (objectsRead) {
            p.pOlnI("} catch (java.lang.ClassNotFoundException e) {");
            p.pln("throw new " + idUnmarshalException +
                "(\"error unmarshalling arguments\", e);");
        }
        p.pOlnI("} finally {");
        p.pln("call.releaseInputStream();");
        p.pOln("}");
    } else {
        p.pln("call.releaseInputStream();");
    }

    if (!returnType.isType(TC_VOID)) {
        /*
         * Declare variable to hold return type, if not void.
         */
        p.p(returnType + " $result = ");            // REMIND: why $?
    }

    /*
     * Invoke the method on the server object.
     */
    p.p("server." + methodName + "(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    /*
     * Always invoke getResultStream(true) on the call object to send
     * the indication of a successful invocation to the caller.  If
     * the return type is not void, keep the result stream and marshal
     * the return value.
     */
    p.plnI("try {");
    if (!returnType.isType(TC_VOID)) {
        p.p("java.io.ObjectOutput out = ");
    }
    p.pln("call.getResultStream(true);");
    if (!returnType.isType(TC_VOID)) {
        writeMarshalArgument(p, "out", returnType, "$result");
        p.pln(";");
    }
    p.pOlnI("} catch (java.io.IOException e) {");
    p.pln("throw new " +
        idMarshalException + "(\"error marshalling return\", e);");
    p.pOln("}");

    p.pln("break;");                // break from switch statement

    p.pOlnI("}");                   // end nested block statement
    p.pln();
}