public override ITypedValue GetValueInternal(ExpressionState state) { if (_name.Equals(_THIS)) { return(state.GetActiveContextObject()); } if (_name.Equals(_ROOT)) { var obj = state.RootContextObject; _exitTypeDescriptor = CodeFlow.ToDescriptorFromObject(obj.Value); return(obj); } var result = state.LookupVariable(_name); var value = result.Value; if (value == null || !value.GetType().IsPublic) { // If the type is not public then when generateCode produces a checkcast to it // then an IllegalAccessError will occur. // If resorting to Object isn't sufficient, the hierarchy could be traversed for // the first public type. _exitTypeDescriptor = "Ljava/lang/Object"; } else { _exitTypeDescriptor = CodeFlow.ToDescriptorFromObject(value); } // a null value will mean either the value was null or the variable was not found return(result); }
public override ITypedValue GetValueInternal(ExpressionState state) { var value = state.LookupVariable(_name); if (value == TypedValue.NULL) { throw new SpelEvaluationException(StartPosition, SpelMessage.FUNCTION_NOT_DEFINED, _name); } if (value.Value is not MethodInfo) { // Possibly a static Java method registered as a function throw new SpelEvaluationException(SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, _name, value.GetType()); } try { return(ExecuteFunctionJLRMethod(state, (MethodInfo)value.Value)); } catch (SpelEvaluationException ex) { ex.Position = StartPosition; throw; } }
protected internal override IValueRef GetValueRef(ExpressionState state) { if (_name.Equals(_THIS)) { return(new TypedValueHolderValueRef(state.GetActiveContextObject(), this)); } if (_name.Equals(_ROOT)) { return(new TypedValueHolderValueRef(state.RootContextObject, this)); } var result = state.LookupVariable(_name); // a null value will mean either the value was null or the variable was not found return(new VariableRef(_name, result, state.EvaluationContext)); }