Mon, 29 Apr 2013 16:51:32 +0400
8011986: [corba] idlj generates read/write union helper methods that throw wrong exception in some cases
Reviewed-by: lancea
src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/UnionGen.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/UnionGen.java Mon Apr 29 16:44:32 2013 +0400 1.2 +++ b/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/UnionGen.java Mon Apr 29 16:51:32 2013 +0400 1.3 @@ -776,7 +776,7 @@ 1.4 stream.println (indent + "if (" + disName + ')'); 1.5 1.6 if (firstBranch == null) 1.7 - stream.println (indent + " throw new org.omg.CORBA.BAD_OPERATION ();"); 1.8 + stream.println (indent + " value._default(" + disName + ");"); 1.9 else { 1.10 stream.println (indent + '{'); 1.11 index = readBranch (index, indent + " ", firstBranch.typedef.name (), 1.12 @@ -787,7 +787,7 @@ 1.13 stream.println (indent + "else"); 1.14 1.15 if (secondBranch == null) 1.16 - stream.println (indent + " throw new org.omg.CORBA.BAD_OPERATION ();"); 1.17 + stream.println (indent + " value._default(" + disName + ");"); 1.18 else { 1.19 stream.println (indent + '{'); 1.20 index = readBranch (index, indent + " ", secondBranch.typedef.name (), 1.21 @@ -937,23 +937,25 @@ 1.22 firstBranch = secondBranch; 1.23 secondBranch = tmp; 1.24 } 1.25 - stream.println (indent + "if (" + disName + ')'); 1.26 - if (firstBranch == null) 1.27 - stream.println (indent + " throw new org.omg.CORBA.BAD_OPERATION ();"); 1.28 - else 1.29 - { 1.30 - stream.println (indent + '{'); 1.31 - index = writeBranch (index, indent + " ", name, firstBranch.typedef, stream); 1.32 - stream.println (indent + '}'); 1.33 - } 1.34 - stream.println (indent + "else"); 1.35 - if (secondBranch == null) 1.36 - stream.println (indent + " throw new org.omg.CORBA.BAD_OPERATION ();"); 1.37 - else 1.38 - { 1.39 - stream.println (indent + '{'); 1.40 - index = writeBranch (index, indent + " ", name, secondBranch.typedef, stream); 1.41 - stream.println (indent + '}'); 1.42 + if (firstBranch != null && secondBranch != null) { 1.43 + stream.println (indent + "if (" + disName + ')'); 1.44 + stream.println (indent + '{'); 1.45 + index = writeBranch (index, indent + " ", name, firstBranch.typedef, stream); 1.46 + stream.println (indent + '}'); 1.47 + stream.println (indent + "else"); 1.48 + stream.println (indent + '{'); 1.49 + index = writeBranch (index, indent + " ", name, secondBranch.typedef, stream); 1.50 + stream.println (indent + '}'); 1.51 + } else if (firstBranch != null) { 1.52 + stream.println (indent + "if (" + disName + ')'); 1.53 + stream.println (indent + '{'); 1.54 + index = writeBranch (index, indent + " ", name, firstBranch.typedef, stream); 1.55 + stream.println (indent + '}'); 1.56 + } else { 1.57 + stream.println (indent + "if (!" + disName + ')'); 1.58 + stream.println (indent + '{'); 1.59 + index = writeBranch (index, indent + " ", name, secondBranch.typedef, stream); 1.60 + stream.println (indent + '}'); 1.61 } 1.62 } 1.63 return index;