4504275: CORBA boolean type unions do not generate compilable code from idlj
authordmeetry
Mon, 29 Apr 2013 16:44:32 +0400
changeset 17218 0007d4b16b10
parent 16981 5ebf6c63714d
child 17219 f0b4ead4fb9f
4504275: CORBA boolean type unions do not generate compilable code from idlj Summary: JLS doesn't allow boolean type in switch statement, hence substituted by if statement. Reviewed-by: lancea
corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/UnionGen.java
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/UnionGen.java	Wed Jul 05 18:52:11 2017 +0200
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/UnionGen.java	Mon Apr 29 16:44:32 2013 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -258,6 +258,19 @@
   {
     Vector labels = vectorizeLabels (u.branches (), true);
 
+    if (Util.javaName(utype).equals ("boolean")) {
+        stream.println( "" ) ;
+        stream.println( "  private void verifyDefault (boolean discriminator)" ) ;
+        stream.println( "  {" ) ;
+        if (labels.contains ("true"))
+            stream.println ("    if ( discriminator )");
+        else
+            stream.println ("    if ( !discriminator )");
+        stream.println( "        throw new org.omg.CORBA.BAD_OPERATION();" ) ;
+        stream.println( "  }" ) ;
+        return;
+    }
+
     stream.println( "" ) ;
     stream.println( "  private void verifyDefault( " + Util.javaName(utype) +
         " value )" ) ;