diff options
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 16 |
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; |