Fix for bug 440689
- Change to DDLParser.jj constructorDeclaration() to account for (>1) constructors within a PL/SQL type
- New test: testTypeWithMultipleConstructors in TypeDDLTestSuite
- Reviewed: David McCann
diff --git a/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.java b/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.java
index feeaa56..8339187 100644
--- a/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.java
+++ b/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.java
@@ -84,7 +84,7 @@
 import static org.eclipse.persistence.tools.oracleddl.metadata.ScalarDatabaseTypeEnum.TIME_TYPE;

 import static org.eclipse.persistence.tools.oracleddl.metadata.ScalarDatabaseTypeEnum.XMLTYPE_TYPE;

 

-@SuppressWarnings("all")
+@SuppressWarnings("all")

 public class DDLParser/*@bgen(jjtree)*/implements DDLParserTreeConstants, DDLParserConstants {/*@bgen(jjtree)*/

   protected JJTDDLParserState jjtree = new JJTDDLParserState();

     protected Map<String, DatabaseType> localTypes = new HashMap<String, DatabaseType>();

@@ -1341,6 +1341,14 @@
     default:

       ;

     }

+    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {

+    case O_COMMA:

+      jj_consume_token(O_COMMA);

+      constructorDeclaration();

+      break;

+    default:

+      ;

+    }

   }

 

   final public void uniqList() throws ParseException {

@@ -3552,8 +3560,9 @@
     catch(LookaheadSuccess ls) { return true; }

   }

 

-  private boolean jj_3R_13() {

-    if (jj_scan_token(R_ANCHORED_TYPE)) return true;

+  private boolean jj_3R_61() {

+    if (jj_scan_token(K_VARYING)) return true;

+    if (jj_scan_token(K_ARRAY)) return true;

     return false;

   }

 

@@ -3562,12 +3571,6 @@
     return false;

   }

 

-  private boolean jj_3R_61() {

-    if (jj_scan_token(K_VARYING)) return true;

-    if (jj_scan_token(K_ARRAY)) return true;

-    return false;

-  }

-

   private boolean jj_3_10() {

     if (jj_3R_12()) return true;

     Token xsp;

@@ -3584,6 +3587,11 @@
     return false;

   }

 

+  private boolean jj_3_8() {

+    if (jj_3R_10()) return true;

+    return false;

+  }

+

   private boolean jj_3R_24() {

     if (jj_scan_token(K_LONG)) return true;

     Token xsp;

@@ -3594,11 +3602,6 @@
     return false;

   }

 

-  private boolean jj_3_8() {

-    if (jj_3R_10()) return true;

-    return false;

-  }

-

   private boolean jj_3R_54() {

     if (jj_scan_token(K_NCHAR)) return true;

     Token xsp;

@@ -3741,11 +3744,6 @@
     return false;

   }

 

-  private boolean jj_3_1() {

-    if (jj_3R_6()) return true;

-    return false;

-  }

-

   private boolean jj_3R_22() {

     if (jj_scan_token(K_SIGNTYPE)) return true;

     return false;

@@ -3759,6 +3757,11 @@
     return false;

   }

 

+  private boolean jj_3_1() {

+    if (jj_3R_6()) return true;

+    return false;

+  }

+

   private boolean jj_3R_21() {

     if (jj_scan_token(K_POSITIVE)) return true;

     return false;

@@ -4643,6 +4646,11 @@
     return false;

   }

 

+  private boolean jj_3R_13() {

+    if (jj_scan_token(R_ANCHORED_TYPE)) return true;

+    return false;

+  }

+

   /** Generated Token Manager. */

   public DDLParserTokenManager token_source;

   JavaCharStream jj_input_stream;

diff --git a/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jj b/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jj
index 623f483..82d39c7 100644
--- a/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jj
+++ b/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jj
Binary files differ
diff --git a/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jjt b/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jjt
index 5fa378d..f35a0b4 100644
--- a/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jjt
+++ b/oracleddlparser/src/main/java/org/eclipse/persistence/tools/oracleddl/parser/DDLParser.jjt
Binary files differ
diff --git a/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/PackagewStronglyTypedCursorDDLTestSuite.java b/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/PackagewStronglyTypedCursorDDLTestSuite.java
index 563f33e..708b5a6 100644
--- a/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/PackagewStronglyTypedCursorDDLTestSuite.java
+++ b/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/PackagewStronglyTypedCursorDDLTestSuite.java
@@ -142,7 +142,11 @@
         String msg = null;
         try {
             String schema = System.getProperty(DATABASE_USERNAME_KEY, DEFAULT_DATABASE_USERNAME);
-            packageType = dtBuilder.buildPackages(conn, schema, STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE).get(0);
+            List<PLSQLPackageType> packages = dtBuilder.buildPackages(conn, schema, STRONGLY_TYPED_REF_CURSOR_TEST_PACKAGE);
+            packageType = packages.get(0);
+            List<ProcedureType> procedures = packageType.getProcedures();
+            assertTrue(procedures.size() == 1);
+            procType = procedures.get(0);
         }
         catch (Exception e) {
             worked = false;
diff --git a/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/ddlparser/TypeDDLTestSuite.java b/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/ddlparser/TypeDDLTestSuite.java
index fcaf539..2095fcc 100644
--- a/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/ddlparser/TypeDDLTestSuite.java
+++ b/oracleddlparser/src/test/java/org/eclipse/persistence/tools/oracleddl/test/ddlparser/TypeDDLTestSuite.java
@@ -263,5 +263,29 @@
         assertEquals("incorrect type name " + TYPE_W_KEYWORDS,

             TYPE_W_KEYWORDS, typeWithKeyword.getTypeName());

     }

+    

+    static final String TYPE_NAME = "CUSTOM_CONS_TYPE";

+    static final String CREATE_TYPE_WITH_MULTIPLE_CONSTRUCTORS = CREATE_TYPE_PREFIX + TYPE_NAME + " AS OBJECT(" +

+            "\n    status varchar2(5)," +

+            "\n    orauser varchar2(40)," +

+            "\n    comments varchar2(1000)," +

+            "\nconstructor function " + TYPE_NAME + "(i_status in boolean, i_orauser in varchar2, i_comments in varchar2) return self as result," +

+            "\nconstructor function " + TYPE_NAME + "(i_status in varchar2, i_comments in varchar2) return self as result," +

+            "\nconstructor function " + TYPE_NAME + "(i_status in varchar2) return self as result)";

+    @Test

+    public void testTypeWithMultipleConstructors() {

+        parser.ReInit(new StringReader(CREATE_TYPE_WITH_MULTIPLE_CONSTRUCTORS));

+        boolean worked = true;

+        String message = "";

+        ObjectType typeWithMultipleConstructors = null;

+        try {

+            typeWithMultipleConstructors = (ObjectType)parser.parseType();

+        } catch (ParseException pe) {

+            message = pe.getMessage();

+            worked = false;

+        }

+        assertTrue("type with multiple constructors did not parse:\n" + message, worked);

+        assertEquals("incorrect type name " + TYPE_NAME, TYPE_NAME, typeWithMultipleConstructors.getTypeName());

+    }

 

 }
\ No newline at end of file