summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-01-19 16:21:07 -0500
committerBernard Normier <bernard@zeroc.com>2017-01-19 16:21:07 -0500
commita7a1e11a3d1f32e71ea24596fec6645ecd669419 (patch)
treee8b365a2fb897023965b2a26f7385c56bfb7d242 /cpp/src/slice2java/Gen.cpp
parentFixed cross-testing objective-c/python (diff)
downloadice-a7a1e11a3d1f32e71ea24596fec6645ecd669419.tar.bz2
ice-a7a1e11a3d1f32e71ea24596fec6645ecd669419.tar.xz
ice-a7a1e11a3d1f32e71ea24596fec6645ecd669419.zip
java:UserException metadata for both local and remote operations
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp58
1 files changed, 27 insertions, 31 deletions
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))
{