summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index e49e502d8f7..d802e9388b0 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -3600,10 +3600,17 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << name << "Prx __d = null;";
out << nl << "if(__obj != null)";
out << sb;
+ out << nl << "try";
+ out << sb;
+ out << nl << "__d = (" << name << "Prx)__obj;";
+ out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
out << nl << "__h.__copyFrom(__obj);";
out << nl << "__d = __h;";
out << eb;
+ out << eb;
out << nl << "return __d;";
out << eb;