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

NoSuchMethodError on JIT Compilation of non-primitive comparison

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 6.3.0.Beta2
    • Fix Version/s: 6.3.0.CR1
    • Component/s: core engine
    • Labels:
      None

      Description

      A LHS like this:

      $map : Map()
      $simpleTestObject : NonStringConstructorClass (something=="simpleTestObject")
      Entry (
        getKey() == $simpleTestObject
      ) from $map.entrySet()
      

      fails at runtime with a NoSuchMethodError, when incompatible objects are compared (Map with object vs. custom Object) and the execution is jitted.

      The generated evaluation method looks like this:

        public boolean evaluate(InternalFactHandle paramInternalFactHandle, InternalWorkingMemory paramInternalWorkingMemory, LeftTuple paramLeftTuple)
        {
          LeftTuple localLeftTuple = paramLeftTuple;
          NonStringConstructorClass localNonStringConstructorClass2 = (NonStringConstructorClass)this.declarations[0].getValue(paramInternalWorkingMemory, localLeftTuple.getHandle().getObject());
          Object localObject = ((Map.Entry)paramInternalFactHandle.getObject()).getKey();
          NonStringConstructorClass localNonStringConstructorClass1 = localNonStringConstructorClass2;
          if (localObject != null)
          {
            if ((localObject instanceof NonStringConstructorClass)) {
              localObject = (NonStringConstructorClass)localObject;
            } else {
              localObject = new NonStringConstructorClass(localObject.toString());
            }
          }
          else
          {
            tmpTernaryOp = (localNonStringConstructorClass1 != null ? 0 : true;
            break label123;
          }
          label123:
          return localNonStringConstructorClass1 == null ? false : ((NonStringConstructorClass)localObject).equals(localNonStringConstructorClass1);
        }
      }
      

      It seem that, a fallback for primitive types was included, by calling the constructor of an object with the object's toString() output:

      localObject = new NonStringConstructorClass(localObject.toString());
      

      At runtime this fails, if no such constructor exists.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mfusco Mario Fusco
                Reporter:
                sdirbach Sascha Dirbach
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: