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

Operators on java.lang.Comparable object doesn't work if JIT is enable

    Details

      Description

      In my application, i have rules that used org.joda.time.LocalDate to compare date like

       
      rule "toto"
      	when
      		LocalDateForDroolsTestBean(
      			infDate>=supDate
      		)
      	then
      		//Anything
      end
      

      With Drools 5.3, all works fine.

      With Drools 5.5, an exception occured because JIT optimizer automaticaly enabled:

       
      Exception in thread "main" java.lang.NoSuchMethodError: org.joda.time.LocalDate.compareTo(Lorg/joda/time/LocalDate;)I
      	at ConditionEvaluatorf8ba8fa3003345adbf3979e901488f23.evaluate(Unknown Source)
      	at org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:200)
      	at org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:157)
      	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
      	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
      	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
      	at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
      	at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
      	at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
      	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
      	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
      	at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
      	at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:304)
      	at fr.jsoula.jboss.drools.bugs.comparable.ComparableBug.main(ComparableBug.java:39)
      

      After search, it seems that the bytecode generated by org.drools.rule.builder.dialect.asm.ClassGenerator can't call the method public int compareTo(Object partial) of org.joda.time.LocalDate. The parameter of the method must be the same class of the current object.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mfusco Mario Fusco
                Reporter:
                jsoula Jérémy SOULA
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: