jakartaee / expression-language

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

Support for Generic Types #7

Closed glassfishrobot closed 11 years ago

glassfishrobot commented 14 years ago

When we have a class like:

public class GenericsTestController {

private E value;

public E getValue()

{ return value; }

public void setValue(E value)

{ this.value = value; }

}

And we have this class to use as a managed bean (integerTest): public class IntegerTestController extends GenericsTestController {

public String add()

{ setValue(getValue()+1); return null; }

public String subtract()

{ setValue(getValue()-1); return null; }

}

This JSF code will not work:

Value: With this error: java.lang.ClassCastException: java.lang.String cannot be cast to Java.lang.Integer at genericstest.IntegerTestController.add(IntegerTestController.java:18) The problem is with section 2.2.7 of the specification (1.1): The provided property will first be coerced to a String. If there is a BeanInfoProperty for this property and there were no errors retrieving it, the propertyType of the propertyDescriptor is returned. Otherwise, a PropertyNotFoundException is thrown. The propertyType of a generic property is Object.class, that gets coerced to String.class, and we get the ClassCastException. #### Environment Operating System: All Platform: All #### Affected Versions [current]
glassfishrobot commented 6 years ago
glassfishrobot commented 14 years ago

@glassfishrobot Commented Reported by josefreire

glassfishrobot commented 14 years ago

@glassfishrobot Commented josefreire said: Created an attachment (id=1) Proposed patch

glassfishrobot commented 13 years ago

@glassfishrobot Commented josefreire said: Could someone please look at this issue?

It's been around for some time, and already has a proposed patch.

glassfishrobot commented 12 years ago

@glassfishrobot Commented josefreire said: This issue can be closed.

With Java 7, the Introspector correctly returns the property type if the class is generic.

glassfishrobot commented 11 years ago

@glassfishrobot Commented kchung said: work with jdk 7.

glassfishrobot commented 14 years ago

@glassfishrobot Commented File: issue-7-proposedpatch.diff Attached By: josefreire

glassfishrobot commented 7 years ago

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

glassfishrobot commented 11 years ago

@glassfishrobot Commented Marked as fixed on Thursday, March 14th 2013, 11:26:54 am