Closed glassfishrobot closed 2 years ago
@glassfishrobot Commented Reported by kbennett2807
@glassfishrobot Commented ren.zhijun.oracle said: Please provide the reproducer and related steps.
@glassfishrobot Commented Was assigned to ren.zhijun.oracle
@glassfishrobot Commented This issue was imported from java.net JIRA UEL-43
This is as expected. The BeanELResolver resolves bean properties per the JavaBeans specification that that specification does not support default methods (it pre-dates them by quite some time).
Whether the JavaBeans specification should be updated is out of scope for this project.
Whether the EL specification should be modified to handle this use case is TBD. Any change would have to wait until Jakarta EE 10 at the earliest. I'll tag this issue as a potential enhancement fo rthat iteration.
Coming back to this now we can start to evolve the APIs. This can be fixed without changing the public API but it is still a behavioural change which will require changes to the spec document, the Javadoc and the TCK as well as the API.
I have an interface that uses Java 8 default methods for a number of it's getters. There are various concrete classes which implement the interface and don't provide their own implementations.
Trying to access these methods/properties within the expression language results in a PropertyNotFoundException.
e.g.
public interface SomeInterface{
default String getDefaultProperty()
{ return "default"; }
...
Implementer implements SomeInterface
...
${implementer.defaultProperty)
causes
javax.el.PropertyNotFoundException: Property 'defaultProperty' not found on type test.Implementer at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:214) at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:191) at javax.el.BeanELResolver.property(BeanELResolver.java:300) at javax.el.BeanELResolver.getValue(BeanELResolver.java:81) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at org.apache.el.parser.AstValue.getValue(AstValue.java:123) at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37) at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37) at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:916) ...
Providing implementations in the concrete classes that call Interface.super is a workaround but kind of defeats the purpose of the default methods.
Affected Versions
[current]