-
Bug
-
Resolution: Done
-
Major
-
6.3.0.Beta2
-
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.