Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-6032

Class name conflict by class "D" in exec-model

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • 7.50.0.Final
    • executable model
    • None
    • Undefined
    • NEW
    • NEW
    • ---
    • ---

      If you use a fact class named "D", you will hit errors during executable-model code generation.

          @Test
          public void testClassNameConflict() {
              String str =
                      "import " + D.class.getCanonicalName() + ";" +
                      "rule R when\n" +
                      "  D(name == \"John\")\n" +
                      "then\n" +
                      "end";
      
              KieSession ksession = getKieSession( str );
      
              D fact = new D("John");
              ksession.insert( fact );
              assertEquals(1, ksession.fireAllRules());
          }
      
          public static class D {
      
              private String name;
      
              public D(String name) {
                  this.name = name;
              }
      
              public String getName() {
                  return name;
              }
      
              public void setName(String name) {
                  this.name = name;
              }
      
          }
      
      [ERROR]   CompilerTest.testClassNameConflict:2573->BaseModelTest.getKieSession:111->BaseModelTest.getKieSession:115->BaseModelTest.getKieContainer:119->BaseModelTest.getKieContainer:126->BaseModelTest.createKieBuilder:137->BaseModelTest.createKieBuilder:164 [Message [id=1, level=ERROR, path=src/main/java/defaultpkg/RulesF625E96E2F948CA04652DBAC4C6DBB79.java, line=5, column=1
         text=a type with the same simple name is already defined by the single-type-import of org.drools.modelcompiler.dsl.pattern.D], Message [id=2, level=ERROR, path=src/main/java/defaultpkg/RulesF625E96E2F948CA04652DBAC4C6DBB79.java, line=0, column=0
         text=Java source of src/main/java/defaultpkg/RulesF625E96E2F948CA04652DBAC4C6DBB79.java in error:
      package defaultpkg;
      
      import org.drools.modelcompiler.dsl.pattern.D;
      import org.drools.model.Index.ConstraintType;
      import org.drools.modelcompiler.CompilerTest.D;
      ...
      

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: