summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-03-26 04:32:42 +0000
committerMichi Henning <michi@zeroc.com>2004-03-26 04:32:42 +0000
commit4648cccd154c9fafec5b92664d7175643e0b7665 (patch)
treed4cb54abc713dc69b9eef7a06a098538c6aeecdd /cpp/src/slice2java/Gen.cpp
parentAdded initialization for Ice.ProgramName from argv[0]. (diff)
downloadice-4648cccd154c9fafec5b92664d7175643e0b7665.tar.bz2
ice-4648cccd154c9fafec5b92664d7175643e0b7665.tar.xz
ice-4648cccd154c9fafec5b92664d7175643e0b7665.zip
Fixed parser bug: if an operation had an exception speficiation with
multiple exceptions, and one of the exceptions was a base of one or more of the other exceptions, the catch blocks in the marshaling and dispatch code were emitted in the wrong order.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index c4bd9958835..c383003f6f7 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -479,6 +479,14 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
throws.unique();
remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal));
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
+ throws.sort(Slice::DerivedToBaseCompare());
+
TypeStringList::const_iterator q;
int iter;
@@ -3025,6 +3033,14 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
throws.unique();
throws.erase(remove_if(throws.begin(), throws.end(), IceUtil::constMemFun(&Exception::isLocal)), throws.end());
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
+ throws.sort(Slice::DerivedToBaseCompare());
+
vector<string> params = getParams(op, package);
out << sp;