On 19/07/2013 18:53, Violeta Georgieva wrote: > Hi, > > I tried to test the different o.a.el.stream.Optional methods. > > Again I used one of our tests and modify > it: (o.a.el.stream.TestCollectionOperations.testAverage03()) > > > [].stream().average().orElseGet(()->64) > > > I received: > > javax.el.ELException: Cannot convert 64 of type class java.lang.Long to > class javax.el.LambdaExpression > at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:482) > at > org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:48) > at javax.el.Util.buildParameters(Util.java:351) > at javax.el.BeanELResolver.invoke(BeanELResolver.java:173) > at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:84) > at org.apache.el.parser.AstValue.getValue(AstValue.java:146) > at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188) > at javax.el.ELProcessor.getValue(ELProcessor.java:45) > > > The problem is the following: > > When in o.a.el.parser.AstValue.getValue(EvaluationContext) > > AstMethodParameters mps = > (AstMethodParameters) this.children[i+1]; -> This > returns ()->64 > // This is a method > base = resolver.invoke(ctx, base, suffix, null, > mps.getParameters(ctx)); -> when > getParameters is invoked the lambda expression is evaluated and 64 is > returned as a result > > > Then BeanElResolver tries to invoke > o.a.el.stream.Optional.orElseGet(LambdaExpression) with Long and not with > LambdaExpression.
I've been comparing Tomcat's behaviour with the RI and it appears that the parser in the RI always reports lambda expressions with parameters as functions whereas Tomcat doesn't. I'm taking a close look at the grammar so see why that might be the case. If lambda expressions with parameters were always reported as functions that might remove the need for a lot of the logic I have been tinkering with in AstLambdaExpression. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org