Java Code Examples for sun.rmi.rmic.IndentingWriter#pOlnI()

The following examples show how to use sun.rmi.rmic.IndentingWriter#pOlnI() . 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: StubGenerator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 2
Source File: StubGenerator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 3
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 4
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 5
Source File: StubGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 6
Source File: StubGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 7
Source File: StubGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 8
Source File: StubGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 9
Source File: StubGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 10
Source File: StubGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 11
Source File: StubGenerator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 12
Source File: StubGenerator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 13
Source File: StubGenerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 14
Source File: StubGenerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}
 
Example 15
Source File: StubGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void writeLocalStubMethodBody (IndentingWriter p,
                               CompoundType.Method method,
                               CompoundType theType) throws IOException {

    String objName;
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getStubExceptions(method,false);
    String methodName = method.getName();
    String methodIDLName = method.getIDLName();

    p.plnI("if (!Util.isLocal(this)) {");
    writeNonLocalStubMethodBody(p,method,theType);
    p.pOlnI("} else {");
    String so = getVariableName("so");

    p.pln("ServantObject "+so+" = _servant_preinvoke(\""+methodIDLName+"\","+getName(theType)+".class);");
    p.plnI("if ("+so+" == null) {");
    if (!returnType.isType(TYPE_VOID)) {
        p.p("return ");
    }
    p.p(methodName+"(");
    for (int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");
    if (returnType.isType(TYPE_VOID)) {
        p.pln( "return ;" ) ;
    }

    p.pOln("}");
    p.plnI("try {");

    // Generate code to copy required arguments, and
    // get back the names by which all arguments are known...

    String[] argNames = writeCopyArguments(method,p);

    // Now write the method...

    boolean copyReturn = mustCopy(returnType);
    String resultName = null;
    if (!returnType.isType(TYPE_VOID)) {
        if (copyReturn) {
            resultName = getVariableName("result");
            objName = testUtil(getName(returnType), returnType);
            p.p(objName+" "+resultName + " = ");
        } else {
            p.p("return ");
        }
    }
    objName = testUtil(getName(theType), theType);
    p.p("(("+objName+")"+so+".servant)."+methodName+"(");

    for (int i = 0; i < argNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(argNames[i]);
    }

    if (copyReturn) {
        p.pln(");");
        objName = testUtil(getName(returnType), returnType);
        p.pln("return ("+objName+")Util.copyObject("+resultName+",_orb());");
    } else {
        p.pln(");");
    }

    String e1 = getVariableName("ex");
    String e2 = getVariableName("exCopy");
    p.pOlnI("} catch (Throwable "+e1+") {");

    p.pln("Throwable "+e2+" = (Throwable)Util.copyObject("+e1+",_orb());");
    for(int i = 0; i < exceptions.length; i++) {
        if (exceptions[i].getIdentifier() != idRemoteException &&
            exceptions[i].isType(TYPE_VALUE)) {
            // Added for Bug 4818753
            p.plnI("if ("+e2+" instanceof "+getExceptionName(exceptions[i])+") {");
            p.pln("throw ("+getExceptionName(exceptions[i])+")"+e2+";");
            p.pOln("}");
        }
    }

    p.pln("throw Util.wrapException("+e2+");");
    p.pOlnI("} finally {");
    p.pln("_servant_postinvoke("+so+");");
    p.pOln("}");
    p.pOln("}");
}
 
Example 16
Source File: StubGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void writeTieMethod(IndentingWriter p, CompoundType type,
                    CompoundType.Method method) throws IOException {
    String methodName = method.getName();
    Type paramTypes[] = method.getArguments();
    String paramNames[] = method.getArgumentNames();
    Type returnType = method.getReturnType();
    ValueType[] exceptions = getTieExceptions(method);
    String in = getVariableName("in");
    String ex = getVariableName("ex");
    String out = getVariableName("out");
    String reply = getVariableName("reply");

    for (int i = 0; i < paramTypes.length; i++) {
        p.p(getName(paramTypes[i])+" "+paramNames[i]+" = ");
        writeUnmarshalArgument(p, in, paramTypes[i], null);
        p.pln();
    }

    boolean handleExceptions = exceptions != null;
    boolean doReturn = !returnType.isType(TYPE_VOID);

    if (handleExceptions && doReturn) {
        String objName = testUtil(getName(returnType), returnType);
        p.pln(objName+" result;");
    }

    if (handleExceptions)
        p.plnI("try {");

    if (doReturn) {
        if (handleExceptions) {
            p.p("result = ");
        } else {
            p.p(getName(returnType)+" result = ");
        }
    }

    p.p("target."+methodName+"(");
    for(int i = 0; i < paramNames.length; i++) {
        if (i > 0)
            p.p(", ");
        p.p(paramNames[i]);
    }
    p.pln(");");

    if (handleExceptions) {
        for(int i = 0; i < exceptions.length; i++) {
            p.pOlnI("} catch ("+getName(exceptions[i])+" "+ex+") {");

            // Is this our IDLEntity Exception special case?

            if (exceptions[i].isIDLEntityException() && !exceptions[i].isCORBAUserException()) {

                            // Yes...

                String helperName = IDLNames.replace(exceptions[i].getQualifiedIDLName(false),"::",".");
                helperName += "Helper";
                p.pln(idOutputStream+" "+out +" = "+reply+".createExceptionReply();");
                p.pln(helperName+".write("+out+","+ex+");");

            } else {

                            // No...

                p.pln("String id = \"" + getExceptionRepositoryID(exceptions[i]) + "\";");
            p.plnI(idExtOutputStream + " "+out+" = ");
            p.pln("(" + idExtOutputStream + ") "+reply+".createExceptionReply();");
            p.pOln(out+".write_string(id);");
                p.pln(out+".write_value("+ex+"," + getName(exceptions[i]) + ".class);");
            }

            p.pln("return "+out+";");
        }
        p.pOln("}");
    }

    if (needNewWriteStreamClass(returnType)) {
        p.plnI(idExtOutputStream + " "+out+" = ");
        p.pln("(" + idExtOutputStream + ") "+reply+".createReply();");
        p.pO();
    } else {
        p.pln("OutputStream "+out+" = "+reply+".createReply();");
    }

    if (doReturn) {
        writeMarshalArgument(p, out, returnType, "result");
        p.pln();
    }

    p.pln("return "+out+";");
}