diff options
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 12 | ||||
-rw-r--r-- | cpp/src/slice2confluence/Gen.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 12 | ||||
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 12 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 58 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.h | 5 | ||||
-rw-r--r-- | cpp/src/slice2java/GenCompat.cpp | 78 | ||||
-rw-r--r-- | cpp/src/slice2java/GenCompat.h | 5 | ||||
-rw-r--r-- | cpp/src/slice2objc/ObjCUtil.cpp | 13 | ||||
-rw-r--r-- | java-compat/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java | 4 | ||||
-rw-r--r-- | java-compat/test/src/main/java/test/Ice/exceptions/Test.ice | 4 | ||||
-rw-r--r-- | java-compat/test/src/main/java/test/Ice/exceptions/TestAMD.ice | 4 | ||||
-rw-r--r-- | java-compat/test/src/main/java/test/Ice/exceptions/ThrowerI.java | 4 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java | 6 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/exceptions/Test.ice | 4 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/exceptions/TestAMD.ice | 4 | ||||
-rw-r--r-- | java/test/src/main/java/test/Ice/exceptions/ThrowerI.java | 4 | ||||
-rw-r--r-- | slice/Ice/ServantLocator.ice | 4 |
18 files changed, 77 insertions, 164 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 7441b60aca4..3c6d0ece494 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -227,18 +227,6 @@ public: virtual void visitOperation(const OperationPtr& p) { - if(p->hasMetaData("UserException")) - { - ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); - if(!cl->isLocal()) - { - ostringstream os; - os << "ignoring invalid metadata `UserException': directive applies only to local operations " - << "but enclosing " << (cl->isInterface() ? "interface" : "class") << " `" << cl->name() - << "' is not local"; - emitWarning(p->file(), p->line(), os.str()); - } - } StringList metaData = getMetaData(p); TypePtr returnType = p->returnType(); if(!metaData.empty()) diff --git a/cpp/src/slice2confluence/Gen.cpp b/cpp/src/slice2confluence/Gen.cpp index 44890c0d368..00bd746812d 100644 --- a/cpp/src/slice2confluence/Gen.cpp +++ b/cpp/src/slice2confluence/Gen.cpp @@ -707,14 +707,10 @@ Slice::GeneratorBase::printMetaData(const ContainedPtr& p, bool isUserImplemente userImplementedOnly.push_back("cpp:const"); userImplementedOnly.push_back("cpp:ice_print"); userImplementedOnly.push_back("java:serialVersionUID"); + userImplementedOnly.push_back("java:UserException"); userImplementedOnly.push_back("UserException"); - if (isUserImplemented) - { - - } - - if (!metaData.empty()) + if(!metaData.empty()) { string outString = ""; StringList::const_iterator q = metaData.begin(); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 073ce41241d..49db4f74884 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -4609,18 +4609,6 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p) ami = true; } - if(p->hasMetaData("UserException")) - { - if(!cl->isLocal()) - { - ostringstream ostr; - ostr << "ignoring invalid metadata `UserException': directive applies only to local operations " - << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() - << "' is not local"; - emitWarning(p->file(), p->line(), ostr.str()); - } - } - StringList metaData = p->getMetaData(); metaData.remove("cpp:const"); diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index d29d7546daf..f430dfd5f01 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -2400,18 +2400,6 @@ Slice::CsGenerator::MetaDataVisitor::visitStructEnd(const StructPtr&) void Slice::CsGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) { - if(p->hasMetaData("UserException")) - { - ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); - if(!cl->isLocal()) - { - ostringstream os; - os << "ignoring invalid metadata `UserException': directive applies only to local operations " - << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() - << "' is not local"; - emitWarning(p->file(), p->line(), os.str()); - } - } validate(p); ParamDeclList params = p->parameters(); diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index e9fac1fa5fb..6aee01c293b 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -1008,10 +1008,17 @@ Slice::JavaVisitor::writeMarshalServantResults(Output& out, const string& packag } void -Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList& throws) +Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList& throws, const OperationPtr& op) { Output& out = output(); - if(throws.size() > 0) + + if(op && (op->hasMetaData("java:UserException") || op->hasMetaData("UserException"))) + { + out.inc(); + out << nl << "throws com.zeroc.Ice.UserException"; + out.dec(); + } + else if(throws.size() > 0) { out.inc(); out << nl << "throws "; @@ -1137,14 +1144,14 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) { out << nl << "java.util.concurrent.CompletionStage<" << getResultType(op, package, true, true) << "> " << op->name() << "Async" << spar << params << currentParam << epar; - writeThrowsClause(package, throws); + writeThrowsClause(package, throws, op); out << ';'; } else { out << nl << getResultType(op, package, false, true) << ' ' << fixKwd(op->name()) << spar << params << currentParam << epar; - writeThrowsClause(package, throws); + writeThrowsClause(package, throws, op); out << ';'; } } @@ -1227,7 +1234,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) out << '_' << p->name() << "Disp"; } out << " obj, final com.zeroc.IceInternal.Incoming inS, com.zeroc.Ice.Current current)"; - if(!op->throws().empty()) + if(!op->throws().empty() || op->hasMetaData("java:UserException") || op->hasMetaData("UserException")) { out.inc(); out << nl << "throws com.zeroc.Ice.UserException"; @@ -2263,11 +2270,17 @@ Slice::JavaVisitor::writeServantDocComment(Output& out, const OperationPtr& p, c out << nl << " * @return A completion stage that the servant will complete when the invocation completes."; } - // TBD: Check for UserException metadata - for(map<string, string>::const_iterator i = dc->exceptions.begin(); i != dc->exceptions.end(); ++i) + if(p->hasMetaData("java:UserException") || p->hasMetaData("UserException")) + { + out << nl << " * @throws com.zeroc.Ice.UserException"; + } + else { - out << nl << " * @throws " << fixKwd(i->first) << ' '; - writeDocCommentLines(out, i->second); + for(map<string, string>::const_iterator i = dc->exceptions.begin(); i != dc->exceptions.end(); ++i) + { + out << nl << " * @throws " << fixKwd(i->first) << ' '; + writeDocCommentLines(out, i->second); + } } if(!dc->misc.empty()) @@ -2816,16 +2829,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p) out << "public abstract "; } out << retS << ' ' << fixKwd(opname) << spar << params << epar; - if(p->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws com.zeroc.Ice.UserException"; - out.dec(); - } - else - { - writeThrowsClause(package, throws); - } + writeThrowsClause(package, throws, p); out << ';'; // @@ -5338,16 +5342,8 @@ Slice::Gen::ImplVisitor::writeOperation(Output& out, const string& package, cons out << nl << "@Override"; out << nl << "public " << getResultType(op, package, false, false) << ' ' << fixKwd(opName) << spar << params << epar; - if(op->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws com.zeroc.Ice.UserException"; - out.dec(); - } - else - { - writeThrowsClause(package, throws); - } + writeThrowsClause(package, throws, op); + out << sb; if(initResult(out, package, op)) { @@ -5376,7 +5372,7 @@ Slice::Gen::ImplVisitor::writeOperation(Output& out, const string& package, cons out << nl << "@Override"; out << nl << "public java.util.concurrent.CompletionStage<" << retS << "> " << opName << "Async" << spar << params << currentParam << epar; - writeThrowsClause(package, throws); + writeThrowsClause(package, throws, op); out << sb; if(initResult(out, package, op)) { @@ -5394,7 +5390,7 @@ Slice::Gen::ImplVisitor::writeOperation(Output& out, const string& package, cons out << nl << "@Override"; out << nl << "public " << getResultType(op, package, false, true) << ' ' << fixKwd(opName) << spar << params << currentParam << epar; - writeThrowsClause(package, throws); + writeThrowsClause(package, throws, op); out << sb; if(initResult(out, package, op)) { diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 5e6046bcd85..11c7d0f7e45 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -70,9 +70,10 @@ protected: const std::string&); // - // Generate a throws clause containing only non-local exceptions. + // Generate a throws clause containing only checked exceptions. + // op is provided only when we want to check for the java:UserException metadata // - void writeThrowsClause(const std::string&, const ExceptionList&); + void writeThrowsClause(const std::string&, const ExceptionList&, const OperationPtr& op = 0); // // Generate code to compute a hash code for a type. diff --git a/cpp/src/slice2java/GenCompat.cpp b/cpp/src/slice2java/GenCompat.cpp index 9890c3c68f0..eb0a18ddc4c 100644 --- a/cpp/src/slice2java/GenCompat.cpp +++ b/cpp/src/slice2java/GenCompat.cpp @@ -797,10 +797,17 @@ Slice::JavaCompatVisitor::writeMarshalUnmarshalParams(Output& out, const string& } void -Slice::JavaCompatVisitor::writeThrowsClause(const string& package, const ExceptionList& throws) +Slice::JavaCompatVisitor::writeThrowsClause(const string& package, const ExceptionList& throws, const OperationPtr& op) { Output& out = output(); - if(throws.size() > 0) + + if(op && (op->hasMetaData("java:UserException") || op->hasMetaData("UserException"))) + { + out.inc(); + out << nl << "throws Ice.UserException"; + out.dec(); + } + else if(throws.size() > 0) { out.inc(); out << nl << "throws "; @@ -1224,16 +1231,8 @@ Slice::JavaCompatVisitor::writeDispatchAndMarshalling(Output& out, const ClassDe << typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, optionalMapping && op->returnIsOptional()) << ' ' << opName << spar << params << epar; - if(op->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws Ice.UserException"; - out.dec(); - } - else - { - writeThrowsClause(package, throws); - } + writeThrowsClause(package, throws, op); + out << sb << nl; if(ret) { @@ -2519,16 +2518,7 @@ Slice::GenCompat::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurre out << "Ice.Current " + currentParamName; } out << epar; - if(op->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws Ice.UserException"; - out.dec(); - } - else - { - writeThrowsClause(package, throws); - } + writeThrowsClause(package, throws, op); out << ';'; } @@ -2738,16 +2728,8 @@ Slice::GenCompat::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << "public abstract "; } out << retS << ' ' << fixKwd(opname) << spar << params << epar; - if(op->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws Ice.UserException"; - out.dec(); - } - else - { - writeThrowsClause(package, throws); - } + writeThrowsClause(package, throws, op); + out << ';'; // @@ -5796,19 +5778,11 @@ Slice::GenCompat::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) } out << epar; - if((*r)->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws Ice.UserException"; - out.dec(); - } - else - { - ExceptionList throws = (*r)->throws(); - throws.sort(); - throws.unique(); - writeThrowsClause(package, throws); - } + ExceptionList throws = (*r)->throws(); + throws.sort(); + throws.unique(); + writeThrowsClause(package, throws, *r); + out << sb; out << nl; if(ret && !hasAMD) @@ -6054,7 +6028,7 @@ Slice::GenCompat::BaseImplVisitor::writeOperation(Output& out, const string& pac #else throws.sort(Slice::DerivedToBaseCompare()); #endif - writeThrowsClause(package, throws); + writeThrowsClause(package, throws, op); out << sb; @@ -6116,17 +6090,7 @@ Slice::GenCompat::BaseImplVisitor::writeOperation(Output& out, const string& pac ExceptionList throws = op->throws(); throws.sort(); throws.unique(); - - if(op->hasMetaData("UserException")) - { - out.inc(); - out << nl << "throws Ice.UserException"; - out.dec(); - } - else - { - writeThrowsClause(package, throws); - } + writeThrowsClause(package, throws, op); out << sb; diff --git a/cpp/src/slice2java/GenCompat.h b/cpp/src/slice2java/GenCompat.h index dde47bc772a..5f8ba85aa9d 100644 --- a/cpp/src/slice2java/GenCompat.h +++ b/cpp/src/slice2java/GenCompat.h @@ -64,9 +64,10 @@ protected: const OperationPtr&, int&, bool, bool, bool, const std::string& = "", bool = false); // - // Generate a throws clause containing only non-local exceptions. + // Generate a throws clause containing only checked exceptions. + // op is provided only when we want to check for the java:UserException metadata // - void writeThrowsClause(const std::string&, const ExceptionList&); + void writeThrowsClause(const std::string&, const ExceptionList&, const OperationPtr& op = 0); // // Generate code to compute a hash code for a type. diff --git a/cpp/src/slice2objc/ObjCUtil.cpp b/cpp/src/slice2objc/ObjCUtil.cpp index 99f7f925098..92b4d1cc17f 100644 --- a/cpp/src/slice2objc/ObjCUtil.cpp +++ b/cpp/src/slice2objc/ObjCUtil.cpp @@ -1176,19 +1176,6 @@ Slice::ObjCGenerator::MetaDataVisitor::visitStructEnd(const StructPtr&) void Slice::ObjCGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) { - if(p->hasMetaData("UserException")) - { - ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); - if(!cl->isLocal()) - { - ostringstream os; - os << "ignoring invalid metadata `UserException': directive applies only to local operations " - << ": warning: metadata directive `UserException' applies only to local operations " - << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() - << "' is not local"; - emitWarning(p->file(), p->line(), os.str()); - } - } validate(p); } diff --git a/java-compat/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java b/java-compat/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java index 1b7066269a2..801b0c57d00 100644 --- a/java-compat/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java +++ b/java-compat/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java @@ -176,12 +176,14 @@ public final class AMDThrowerI extends _ThrowerDisp @Override public void throwUndeclaredC_async(AMD_Thrower_throwUndeclaredC cb, int a, int b, int c, Ice.Current current) + throws Ice.UserException { C ex = new C(); ex.aMem = a; ex.bMem = b; ex.cMem = c; - cb.ice_exception(ex); + throw ex; + // cb.ice_exception(ex); } @Override diff --git a/java-compat/test/src/main/java/test/Ice/exceptions/Test.ice b/java-compat/test/src/main/java/test/Ice/exceptions/Test.ice index c9146df6eee..061e697657a 100644 --- a/java-compat/test/src/main/java/test/Ice/exceptions/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/exceptions/Test.ice @@ -53,11 +53,11 @@ interface Thrower void throwCasA(int a, int b, int c) throws A; void throwBasB(int a, int b) throws B; void throwCasB(int a, int b, int c) throws B; - void throwCasC(int a, int b, int c) throws C; + ["java:UserException"] void throwCasC(int a, int b, int c) throws C; void throwUndeclaredA(int a); void throwUndeclaredB(int a, int b); - void throwUndeclaredC(int a, int b, int c); + ["java:UserException"] void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); void throwAssertException(); diff --git a/java-compat/test/src/main/java/test/Ice/exceptions/TestAMD.ice b/java-compat/test/src/main/java/test/Ice/exceptions/TestAMD.ice index d03c7ed7aba..6acec3f7361 100644 --- a/java-compat/test/src/main/java/test/Ice/exceptions/TestAMD.ice +++ b/java-compat/test/src/main/java/test/Ice/exceptions/TestAMD.ice @@ -49,10 +49,10 @@ exception D void throwCasA(int a, int b, int c) throws A; void throwBasB(int a, int b) throws B; void throwCasB(int a, int b, int c) throws B; - void throwCasC(int a, int b, int c) throws C; + ["java:UserException"] void throwCasC(int a, int b, int c) throws C; void throwUndeclaredA(int a); void throwUndeclaredB(int a, int b); - void throwUndeclaredC(int a, int b, int c); + ["java:UserException"] void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); void throwAssertException(); diff --git a/java-compat/test/src/main/java/test/Ice/exceptions/ThrowerI.java b/java-compat/test/src/main/java/test/Ice/exceptions/ThrowerI.java index ead93773148..b8c88eb3ad2 100644 --- a/java-compat/test/src/main/java/test/Ice/exceptions/ThrowerI.java +++ b/java-compat/test/src/main/java/test/Ice/exceptions/ThrowerI.java @@ -139,9 +139,9 @@ public final class ThrowerI extends _ThrowerDisp @Override public void throwUndeclaredC(int a, int b, int c, Ice.Current current) + throws Ice.UserException { - // Not possible in Java. - throw new Ice.UnknownUserException(); + throw new C(a, b, c); } @Override diff --git a/java/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java b/java/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java index 597e22c0760..26a74e56b6d 100644 --- a/java/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java +++ b/java/test/src/main/java/test/Ice/exceptions/AMDThrowerI.java @@ -161,14 +161,16 @@ public final class AMDThrowerI implements Thrower @Override public CompletionStage<Void> throwUndeclaredCAsync(int a, int b, int c, com.zeroc.Ice.Current current) + throws com.zeroc.Ice.UserException { CompletableFuture<Void> r = new CompletableFuture<>(); C ex = new C(); ex.aMem = a; ex.bMem = b; ex.cMem = c; - r.completeExceptionally(ex); - return r; + throw ex; + // r.completeExceptionally(ex); + // return r; } @Override diff --git a/java/test/src/main/java/test/Ice/exceptions/Test.ice b/java/test/src/main/java/test/Ice/exceptions/Test.ice index c9146df6eee..061e697657a 100644 --- a/java/test/src/main/java/test/Ice/exceptions/Test.ice +++ b/java/test/src/main/java/test/Ice/exceptions/Test.ice @@ -53,11 +53,11 @@ interface Thrower void throwCasA(int a, int b, int c) throws A; void throwBasB(int a, int b) throws B; void throwCasB(int a, int b, int c) throws B; - void throwCasC(int a, int b, int c) throws C; + ["java:UserException"] void throwCasC(int a, int b, int c) throws C; void throwUndeclaredA(int a); void throwUndeclaredB(int a, int b); - void throwUndeclaredC(int a, int b, int c); + ["java:UserException"] void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); void throwAssertException(); diff --git a/java/test/src/main/java/test/Ice/exceptions/TestAMD.ice b/java/test/src/main/java/test/Ice/exceptions/TestAMD.ice index d03c7ed7aba..6acec3f7361 100644 --- a/java/test/src/main/java/test/Ice/exceptions/TestAMD.ice +++ b/java/test/src/main/java/test/Ice/exceptions/TestAMD.ice @@ -49,10 +49,10 @@ exception D void throwCasA(int a, int b, int c) throws A; void throwBasB(int a, int b) throws B; void throwCasB(int a, int b, int c) throws B; - void throwCasC(int a, int b, int c) throws C; + ["java:UserException"] void throwCasC(int a, int b, int c) throws C; void throwUndeclaredA(int a); void throwUndeclaredB(int a, int b); - void throwUndeclaredC(int a, int b, int c); + ["java:UserException"] void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); void throwAssertException(); diff --git a/java/test/src/main/java/test/Ice/exceptions/ThrowerI.java b/java/test/src/main/java/test/Ice/exceptions/ThrowerI.java index 9750f60eb54..1ccad19bb84 100644 --- a/java/test/src/main/java/test/Ice/exceptions/ThrowerI.java +++ b/java/test/src/main/java/test/Ice/exceptions/ThrowerI.java @@ -126,9 +126,9 @@ public final class ThrowerI implements Thrower @Override public void throwUndeclaredC(int a, int b, int c, com.zeroc.Ice.Current current) + throws com.zeroc.Ice.UserException { - // Not possible in Java. - throw new com.zeroc.Ice.UnknownUserException(); + throw new C(a, b, c); } @Override diff --git a/slice/Ice/ServantLocator.ice b/slice/Ice/ServantLocator.ice index 8f80ed47e0f..30a00127eed 100644 --- a/slice/Ice/ServantLocator.ice +++ b/slice/Ice/ServantLocator.ice @@ -73,7 +73,7 @@ local interface ServantLocator * @see #finished * **/ - ["UserException"] Object locate(Current curr, out LocalObject cookie); + ["java:UserException"] Object locate(Current curr, out LocalObject cookie); /** * @@ -106,7 +106,7 @@ local interface ServantLocator * @see #locate * **/ - ["UserException"] void finished(Current curr, Object servant, LocalObject cookie); + ["java:UserException"] void finished(Current curr, Object servant, LocalObject cookie); /** * |