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

NoSuchMethodError on JIT Compilation of non-primitive comparison

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.3.0.CR1
    • 6.3.0.Beta2
    • core engine
    • None

      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.

              mfusco@redhat.com Mario Fusco
              sascha.dirbach@cloudwerkstatt.com Sascha Tim Dirbach
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: