summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2006-08-04 04:30:39 +0000
committerMichi Henning <michi@zeroc.com>2006-08-04 04:30:39 +0000
commit03611ef2af5765896a5db1ad61406d36fefc18bc (patch)
treed2e94178e86eeb9cb226e912e2badbe1bf5555d6 /cpp/src/slice2java/Gen.cpp
parentFixed bug #1284 (diff)
downloadice-03611ef2af5765896a5db1ad61406d36fefc18bc.tar.bz2
ice-03611ef2af5765896a5db1ad61406d36fefc18bc.tar.xz
ice-03611ef2af5765896a5db1ad61406d36fefc18bc.zip
Bug 1246.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index a5f2244a862..16792718e7f 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -1688,6 +1688,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
out << sb;
+ out << nl << "try";
+ out << sb;
if(allClassMembers.size() > 1)
{
out << nl << "switch(__member)";
@@ -1720,6 +1722,14 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
}
out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
out << sp << nl << "public String" << nl << "type()";
out << sb;
@@ -2015,6 +2025,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
out << sb;
+ out << nl << "try";
+ out << sb;
if(allClassMembers.size() > 1)
{
out << nl << "switch(__member)";
@@ -2047,6 +2059,14 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << eb;
}
out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
out << sp << nl << "public String" << nl << "type()";
out << sb;
@@ -2419,6 +2439,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
out << sb;
+ out << nl << "try";
+ out << sb;
if(classMembers.size() > 1)
{
out << nl << "switch(__member)";
@@ -2451,6 +2473,14 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << eb;
}
out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
out << sp << nl << "public String" << nl << "type()";
out << sb;
@@ -3177,8 +3207,18 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p)
out << nl << "public void";
out << nl << "patch(Ice.Object v)";
out << sb;
+ out << nl << "try";
+ out << sb;
out << nl << "value = (" << typeS << ")v;";
out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
out << sp << nl << "public String" << nl << "type()";
out << sb;