jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
67 stars 49 forks source link

PropertyNotFoundException when property is default method on interface #43

Closed glassfishrobot closed 2 years ago

glassfishrobot commented 8 years ago

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]

glassfishrobot commented 6 years ago
glassfishrobot commented 8 years ago

@glassfishrobot Commented Reported by kbennett2807

glassfishrobot commented 8 years ago

@glassfishrobot Commented ren.zhijun.oracle said: Please provide the reproducer and related steps.

glassfishrobot commented 8 years ago

@glassfishrobot Commented Was assigned to ren.zhijun.oracle

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA UEL-43

markt-asf commented 4 years ago

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.

markt-asf commented 3 years ago

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.