org.springframework.expression.TypedValue Java Examples

The following examples show how to use org.springframework.expression.TypedValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FunctionReference.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	TypedValue value = state.lookupVariable(this.name);
	if (value == null) {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.FUNCTION_NOT_DEFINED, this.name);
	}

	// Two possibilities: a lambda function or a Java static method registered as a function
	if (!(value.getValue() instanceof Method)) {
		throw new SpelEvaluationException(
				SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, this.name, value.getClass());
	}

	try {
		return executeFunctionJLRMethod(state, (Method) value.getValue());
	}
	catch (SpelEvaluationException ex) {
		ex.setPosition(getStartPosition());
		throw ex;
	}
}
 
Example #2
Source File: ExpressionUtils.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines if there is a type converter available in the specified context and
 * attempts to use it to convert the supplied value to the specified type. Throws an
 * exception if conversion is not possible.
 * @param context the evaluation context that may define a type converter
 * @param typedValue the value to convert and a type descriptor describing it
 * @param targetType the type to attempt conversion to
 * @return the converted value
 * @throws EvaluationException if there is a problem during conversion or conversion
 * of the value to the specified type is not supported
 */
@SuppressWarnings("unchecked")
public static <T> T convertTypedValue(EvaluationContext context, TypedValue typedValue, Class<T> targetType) {
	Object value = typedValue.getValue();
	if (targetType == null) {
		return (T) value;
	}
	if (context != null) {
		return (T) context.getTypeConverter().convertValue(
				value, typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(targetType));
	}
	if (ClassUtils.isAssignableValue(targetType, value)) {
		return (T) value;
	}
	throw new EvaluationException("Cannot convert value '" + value + "' to type '" + targetType.getName() + "'");
}
 
Example #3
Source File: PropertyOrFieldReference.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext evalContext)
		throws EvaluationException {

	List<PropertyAccessor> accessorsToTry =
			getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors());
	if (accessorsToTry != null) {
		for (PropertyAccessor accessor : accessorsToTry) {
			try {
				if (accessor.canWrite(evalContext, contextObject.getValue(), name)) {
					return true;
				}
			}
			catch (AccessException ex) {
				// let others try
			}
		}
	}
	return false;
}
 
Example #4
Source File: ReflectiveConstructorExecutor.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException {
	try {
		if (arguments != null) {
			ReflectionHelper.convertArguments(context.getTypeConverter(), arguments, this.ctor, this.varargsPosition);
		}
		if (this.ctor.isVarArgs()) {
			arguments = ReflectionHelper.setupArgumentsForVarargsInvocation(this.ctor.getParameterTypes(), arguments);
		}
		ReflectionUtils.makeAccessible(this.ctor);
		return new TypedValue(this.ctor.newInstance(arguments));
	}
	catch (Exception ex) {
		throw new AccessException("Problem invoking constructor: " + this.ctor, ex);
	}
}
 
Example #5
Source File: FunctionReference.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	TypedValue value = state.lookupVariable(this.name);
	if (value == null) {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.FUNCTION_NOT_DEFINED, this.name);
	}

	// Two possibilities: a lambda function or a Java static method registered as a function
	if (!(value.getValue() instanceof Method)) {
		throw new SpelEvaluationException(
				SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, this.name, value.getClass());
	}

	try {
		return executeFunctionJLRMethod(state, (Method) value.getValue());
	}
	catch (SpelEvaluationException ex) {
		ex.setPosition(getStartPosition());
		throw ex;
	}
}
 
Example #6
Source File: BeanReference.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver();
	if (beanResolver == null) {
		throw new SpelEvaluationException(
				getStartPosition(), SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanName);
	}

	try {
		return new TypedValue(beanResolver.resolve(state.getEvaluationContext(), this.beanName));
	}
	catch (AccessException ex) {
		throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,
			this.beanName, ex.getMessage());
	}
}
 
Example #7
Source File: PropertyOrFieldReference.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext evalContext)
		throws EvaluationException {

	List<PropertyAccessor> accessorsToTry =
			getPropertyAccessorsToTry(contextObject.getValue(), evalContext.getPropertyAccessors());
	if (accessorsToTry != null) {
		for (PropertyAccessor accessor : accessorsToTry) {
			try {
				if (accessor.canWrite(evalContext, contextObject.getValue(), name)) {
					return true;
				}
			}
			catch (AccessException ex) {
				// let others try
			}
		}
	}
	return false;
}
 
Example #8
Source File: OpPlusTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void test_binaryPlusWithTime_ToString() {

	ExpressionState expressionState = new ExpressionState(new StandardEvaluationContext());

	Time time = new Time(new Date().getTime());

	VariableReference var = new VariableReference("timeVar", -1);
	var.setValue(expressionState, time);

	StringLiteral n2 = new StringLiteral("\" is now\"", -1, "\" is now\"");
	OpPlus o = new OpPlus(-1, var, n2);
	TypedValue value = o.getValueInternal(expressionState);

	assertEquals(String.class, value.getTypeDescriptor().getObjectType());
	assertEquals(String.class, value.getTypeDescriptor().getType());
	assertEquals(time + " is now", value.getValue());
}
 
Example #9
Source File: BeanReference.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver();
	if (beanResolver == null) {
		throw new SpelEvaluationException(
				getStartPosition(), SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanName);
	}

	try {
		return new TypedValue(beanResolver.resolve(state.getEvaluationContext(), this.beanName));
	}
	catch (AccessException ex) {
		throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,
			this.beanName, ex.getMessage());
	}
}
 
Example #10
Source File: ReflectiveConstructorExecutor.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException {
	try {
		ReflectionHelper.convertArguments(
				context.getTypeConverter(), arguments, this.ctor, this.varargsPosition);
		if (this.ctor.isVarArgs()) {
			arguments = ReflectionHelper.setupArgumentsForVarargsInvocation(
					this.ctor.getParameterTypes(), arguments);
		}
		ReflectionUtils.makeAccessible(this.ctor);
		return new TypedValue(this.ctor.newInstance(arguments));
	}
	catch (Exception ex) {
		throw new AccessException("Problem invoking constructor: " + this.ctor, ex);
	}
}
 
Example #11
Source File: ConstructorReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void populateIntArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
		InlineList initializer) {

	int[] newIntArray = (int[]) newArray;
	for (int i = 0; i < newIntArray.length; i++) {
		TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
		newIntArray[i] = ExpressionUtils.toInt(typeConverter, typedValue);
	}
}
 
Example #12
Source File: ConstructorReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void populateBooleanArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
		InlineList initializer) {

	boolean[] newBooleanArray = (boolean[]) newArray;
	for (int i = 0; i < newBooleanArray.length; i++) {
		TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
		newBooleanArray[i] = ExpressionUtils.toBoolean(typeConverter, typedValue);
	}
}
 
Example #13
Source File: OpPlusTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void test_binaryPlusWithLeftStringOperand() {
	ExpressionState expressionState = new ExpressionState(new StandardEvaluationContext());

	StringLiteral n1 = new StringLiteral("\"number is \"", -1, "\"number is \"");
	LongLiteral n2 = new LongLiteral("123", -1, 123);
	OpPlus o = new OpPlus(-1, n1, n2);
	TypedValue value = o.getValueInternal(expressionState);

	assertEquals(String.class, value.getTypeDescriptor().getObjectType());
	assertEquals(String.class, value.getTypeDescriptor().getType());
	assertEquals("number is 123", value.getValue());
}
 
Example #14
Source File: MapPropertyAccessor.java    From kork with Apache License 2.0 5 votes vote down vote up
@Override
public TypedValue read(final EvaluationContext context, final Object target, final String name)
    throws AccessException {
  try {
    return super.read(context, target, name);
  } catch (AccessException ae) {
    if (allowUnknownKeys) {
      return TypedValue.NULL;
    }
    throw ae;
  }
}
 
Example #15
Source File: OpPlusTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void test_binaryPlusWithRightStringOperand() {
	ExpressionState expressionState = new ExpressionState(new StandardEvaluationContext());

	LongLiteral n1 = new LongLiteral("123", -1, -1, 123);
	StringLiteral n2 = new StringLiteral("\" is a number\"", -1, -1, "\" is a number\"");
	OpPlus o = new OpPlus(-1, -1, n1, n2);
	TypedValue value = o.getValueInternal(expressionState);

	assertEquals(String.class, value.getTypeDescriptor().getObjectType());
	assertEquals(String.class, value.getTypeDescriptor().getType());
	assertEquals("123 is a number", value.getValue());
}
 
Example #16
Source File: OperatorPower.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	SpelNodeImpl leftOp = getLeftOperand();
	SpelNodeImpl rightOp = getRightOperand();

	Object leftOperand = leftOp.getValueInternal(state).getValue();
	Object rightOperand = rightOp.getValueInternal(state).getValue();

	if (leftOperand instanceof Number && rightOperand instanceof Number) {
		Number leftNumber = (Number) leftOperand;
		Number rightNumber = (Number) rightOperand;

		if (leftNumber instanceof BigDecimal) {
			BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class);
			return new TypedValue(leftBigDecimal.pow(rightNumber.intValue()));
		}
		else if (leftNumber instanceof BigInteger) {
			BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class);
			return new TypedValue(leftBigInteger.pow(rightNumber.intValue()));
		}
		else if (leftNumber instanceof Double || rightNumber instanceof Double) {
			return new TypedValue(Math.pow(leftNumber.doubleValue(), rightNumber.doubleValue()));
		}
		else if (leftNumber instanceof Float || rightNumber instanceof Float) {
			return new TypedValue(Math.pow(leftNumber.floatValue(), rightNumber.floatValue()));
		}

		double d = Math.pow(leftNumber.doubleValue(), rightNumber.doubleValue());
		if (d > Integer.MAX_VALUE || leftNumber instanceof Long || rightNumber instanceof Long) {
			return new TypedValue((long) d);
		}
		else {
			return new TypedValue((int) d);
		}
	}

	return state.operate(Operation.POWER, leftOperand, rightOperand);
}
 
Example #17
Source File: SpelExpression.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException {
	if (this.compiledAst != null) {
		try {
			EvaluationContext context = getEvaluationContext();
			Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context);
			if (expectedResultType == null) {
				return (T) result;
			}
			else {
				return ExpressionUtils.convertTypedValue(
						getEvaluationContext(), new TypedValue(result), expectedResultType);
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount.set(0);
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(getEvaluationContext(), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(
			expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
}
 
Example #18
Source File: OperatorPower.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	SpelNodeImpl leftOp = getLeftOperand();
	SpelNodeImpl rightOp = getRightOperand();

	Object leftOperand = leftOp.getValueInternal(state).getValue();
	Object rightOperand = rightOp.getValueInternal(state).getValue();

	if (leftOperand instanceof Number && rightOperand instanceof Number) {
		Number leftNumber = (Number) leftOperand;
		Number rightNumber = (Number) rightOperand;

		if (leftNumber instanceof BigDecimal) {
			BigDecimal leftBigDecimal = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class);
			return new TypedValue(leftBigDecimal.pow(rightNumber.intValue()));
		}
		else if (leftNumber instanceof BigInteger) {
			BigInteger leftBigInteger = NumberUtils.convertNumberToTargetClass(leftNumber, BigInteger.class);
			return new TypedValue(leftBigInteger.pow(rightNumber.intValue()));
		}
		else if (leftNumber instanceof Double || rightNumber instanceof Double) {
			return new TypedValue(Math.pow(leftNumber.doubleValue(), rightNumber.doubleValue()));
		}
		else if (leftNumber instanceof Float || rightNumber instanceof Float) {
			return new TypedValue(Math.pow(leftNumber.floatValue(), rightNumber.floatValue()));
		}

		double d = Math.pow(leftNumber.doubleValue(), rightNumber.doubleValue());
		if (d > Integer.MAX_VALUE || leftNumber instanceof Long || rightNumber instanceof Long) {
			return new TypedValue((long) d);
		}
		else {
			return new TypedValue((int) d);
		}
	}

	return state.operate(Operation.POWER, leftOperand, rightOperand);
}
 
Example #19
Source File: ConstructorReference.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void populateByteArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
		InlineList initializer) {

	byte[] newByteArray = (byte[]) newArray;
	for (int i = 0; i < newByteArray.length; i++) {
		TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
		newByteArray[i] = ExpressionUtils.toByte(typeConverter, typedValue);
	}
}
 
Example #20
Source File: OpPlus.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert operand value to string using registered converter or using
 * {@code toString} method.
 * @param value typed value to be converted
 * @param state expression state
 * @return {@code TypedValue} instance converted to {@code String}
 */
private static String convertTypedValueToString(TypedValue value, ExpressionState state) {
	TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();
	TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(String.class);
	if (typeConverter.canConvert(value.getTypeDescriptor(), typeDescriptor)) {
		return String.valueOf(typeConverter.convertValue(value.getValue(),
				value.getTypeDescriptor(), typeDescriptor));
	}
	return String.valueOf(value.getValue());
}
 
Example #21
Source File: MethodReference.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	EvaluationContext evaluationContext = state.getEvaluationContext();
	Object value = state.getActiveContextObject().getValue();
	TypeDescriptor targetType = state.getActiveContextObject().getTypeDescriptor();
	Object[] arguments = getArguments(state);
	TypedValue result = getValueInternal(evaluationContext, value, targetType, arguments);
	updateExitTypeDescriptor();
	return result;
}
 
Example #22
Source File: CompoundExpression.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Evaluates a compound expression. This involves evaluating each piece in turn and the
 * return value from each piece is the active context object for the subsequent piece.
 * @param state the state in which the expression is being evaluated
 * @return the final value from the last piece of the compound expression
 */
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	ValueRef ref = getValueRef(state);
	TypedValue result = ref.getValue();
	this.exitTypeDescriptor = this.children[this.children.length - 1].exitTypeDescriptor;
	return result;
}
 
Example #23
Source File: MethodReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	EvaluationContext evaluationContext = state.getEvaluationContext();
	Object value = state.getActiveContextObject().getValue();
	TypeDescriptor targetType = state.getActiveContextObject().getTypeDescriptor();
	Object[] arguments = getArguments(state);
	TypedValue result = getValueInternal(evaluationContext, value, targetType, arguments);
	updateExitTypeDescriptor();
	return result;
}
 
Example #24
Source File: Indexer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypedValue getValue() {
	if (this.index >= this.target.length()) {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.STRING_INDEX_OUT_OF_BOUNDS,
				this.target.length(), this.index);
	}
	return new TypedValue(String.valueOf(this.target.charAt(this.index)));
}
 
Example #25
Source File: OpAnd.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	if (getBooleanValue(state, getLeftOperand()) == false) {
		// no need to evaluate right operand
		return BooleanTypedValue.FALSE;
	}
	return BooleanTypedValue.forValue(getBooleanValue(state, getRightOperand()));
}
 
Example #26
Source File: ConstructorReference.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void populateIntArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
		InlineList initializer) {

	int[] newIntArray = (int[]) newArray;
	for (int i = 0; i < newIntArray.length; i++) {
		TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
		newIntArray[i] = ExpressionUtils.toInt(typeConverter, typedValue);
	}
}
 
Example #27
Source File: ExpressionState.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The active context object is what unqualified references to properties/etc are resolved against.
 */
public TypedValue getActiveContextObject() {
	if (CollectionUtils.isEmpty(this.contextObjects)) {
		return this.rootObject;
	}
	return this.contextObjects.peek();
}
 
Example #28
Source File: OperatorInstanceof.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Compare the left operand to see it is an instance of the type specified as the
 * right operand. The right operand must be a class.
 * @param state the expression state
 * @return {@code true} if the left operand is an instanceof of the right operand,
 * otherwise {@code false}
 * @throws EvaluationException if there is a problem evaluating the expression
 */
@Override
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	SpelNodeImpl rightOperand = getRightOperand();
	TypedValue left = getLeftOperand().getValueInternal(state);
	TypedValue right = rightOperand.getValueInternal(state);
	Object leftValue = left.getValue();
	Object rightValue = right.getValue();
	BooleanTypedValue result;
	if (rightValue == null || !(rightValue instanceof Class)) {
		throw new SpelEvaluationException(getRightOperand().getStartPosition(),
				SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
				(rightValue == null ? "null" : rightValue.getClass().getName()));
	}
	Class<?> rightClass = (Class<?>) rightValue;
	if (leftValue == null) {
		result = BooleanTypedValue.FALSE;  // null is not an instanceof anything
	}
	else {
		result = BooleanTypedValue.forValue(rightClass.isAssignableFrom(leftValue.getClass()));
	}
	this.type = rightClass;
	if (rightOperand instanceof TypeReference) {
		// Can only generate bytecode where the right operand is a direct type reference,
		// not if it is indirect (for example when right operand is a variable reference)
		this.exitTypeDescriptor = "Z";
	}
	return result;
}
 
Example #29
Source File: Elvis.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Evaluate the condition and if not null, return it.
 * If it is null, return the other value.
 * @param state the expression state
 * @throws EvaluationException if the condition does not evaluate correctly
 * to a boolean or there is a problem executing the chosen alternative
 */
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	TypedValue value = this.children[0].getValueInternal(state);
	// If this check is changed, the generateCode method will need changing too
	if (!StringUtils.isEmpty(value.getValue())) {
		return value;
	}
	else {
		TypedValue result = this.children[1].getValueInternal(state);
		computeExitTypeDescriptor();
		return result;
	}
}
 
Example #30
Source File: OperatorInstanceof.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compare the left operand to see it is an instance of the type specified as the
 * right operand. The right operand must be a class.
 * @param state the expression state
 * @return {@code true} if the left operand is an instanceof of the right operand,
 * otherwise {@code false}
 * @throws EvaluationException if there is a problem evaluating the expression
 */
@Override
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	SpelNodeImpl rightOperand = getRightOperand();
	TypedValue left = getLeftOperand().getValueInternal(state);
	TypedValue right = rightOperand.getValueInternal(state);
	Object leftValue = left.getValue();
	Object rightValue = right.getValue();
	BooleanTypedValue result;
	if (rightValue == null || !(rightValue instanceof Class)) {
		throw new SpelEvaluationException(getRightOperand().getStartPosition(),
				SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
				(rightValue == null ? "null" : rightValue.getClass().getName()));
	}
	Class<?> rightClass = (Class<?>) rightValue;
	if (leftValue == null) {
		result = BooleanTypedValue.FALSE;  // null is not an instanceof anything
	}
	else {
		result = BooleanTypedValue.forValue(rightClass.isAssignableFrom(leftValue.getClass()));
	}
	this.type = rightClass;
	if (rightOperand instanceof TypeReference) {
		// Can only generate bytecode where the right operand is a direct type reference, 
		// not if it is indirect (for example when right operand is a variable reference)
		this.exitTypeDescriptor = "Z";
	}
	return result;
}