DWR

Generics - Type information pulled from Super class - not calling class.

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Normal Normal
  • Resolution: Unresolved
  • Affects Version/s: 3.0.M1, 3.0.RC1
  • Fix Version/s: 4.0
  • Component/s: Core
  • Documentation Required:
    No
  • Description:
    Hide
    Take the following example:

    public class BaseClass <T> {
       public add(T domainObj) { ... }
    }

    public class SubClass extends BaseClass<MyDomainObject> { }

    If SubClass.add is exposed to DWR the user is required to use the JavaScript class mapping feature to successfully call the add method. This is because the type information is pulled from the superclass - not the calling class. This should work out of the box - without JavaScript class mapping.

    See - [dwr-user] DWR does not recognize generic type parameter
    for more information.
    Show
    Take the following example: public class BaseClass <T> {    public add(T domainObj) { ... } } public class SubClass extends BaseClass<MyDomainObject> { } If SubClass.add is exposed to DWR the user is required to use the JavaScript class mapping feature to successfully call the add method. This is because the type information is pulled from the superclass - not the calling class. This should work out of the box - without JavaScript class mapping. See - [dwr-user] DWR does not recognize generic type parameter for more information.
  1. GenericReflectionTest.java
    (3 kB)
    Lance Semmens
    22/Sep/09 4:17 PM

Activity

Hide
Lance Semmens added a comment - 21/Sep/09 2:28 PM

For generic methods (methods with at least one generic parameter or a generic return type). The java.lang.reflect API will return 2 method objects for Class.getMethods(). My gut feeling is that DWR is choosing the method without the type information associated with it. It should instead choose the method where:
java.lang.reflect.Modifier.isVolatile(method.getModifiers()) == false

Show
Lance Semmens added a comment - 21/Sep/09 2:28 PM For generic methods (methods with at least one generic parameter or a generic return type). The java.lang.reflect API will return 2 method objects for Class.getMethods(). My gut feeling is that DWR is choosing the method without the type information associated with it. It should instead choose the method where: java.lang.reflect.Modifier.isVolatile(method.getModifiers()) == false
Hide
Lance Semmens added a comment - 21/Sep/09 2:33 PM

Resolving this issue will most probably resolve DWR-125

Show
Lance Semmens added a comment - 21/Sep/09 2:33 PM Resolving this issue will most probably resolve DWR-125
Hide
David Marginian added a comment - 22/Sep/09 1:18 AM

Lance,
I debugged through this in 3.x and it does not appear to be related to the problem you mention in your previous comments.

Show
David Marginian added a comment - 22/Sep/09 1:18 AM Lance, I debugged through this in 3.x and it does not appear to be related to the problem you mention in your previous comments.
Hide
Lance Semmens added a comment - 22/Sep/09 4:17 PM

The attached file shows how you can access the generic parameter types of a method. It takes a bit of jumping through hoops but it's not impossible.

Show
Lance Semmens added a comment - 22/Sep/09 4:17 PM The attached file shows how you can access the generic parameter types of a method. It takes a bit of jumping through hoops but it's not impossible.
Lance Semmens made changes - 22/Sep/09 4:17 PM
Field Original Value New Value
Attachment GenericReflectionTest.java [ 10242 ]
Hide
David Marginian added a comment - 04/Oct/09 6:01 AM

I am plus one for not doing this, but I would like other opinions. I think doing this opens up a lot of complexity and since it can already be supported by JavaScript class mappings maybe we should just punt? See the last few posts under the dwr-user list thread - DWR does not recognize generic type parameter.

Show
David Marginian added a comment - 04/Oct/09 6:01 AM I am plus one for not doing this, but I would like other opinions. I think doing this opens up a lot of complexity and since it can already be supported by JavaScript class mappings maybe we should just punt? See the last few posts under the dwr-user list thread - DWR does not recognize generic type parameter.
David Marginian made changes - 04/Oct/09 6:01 AM
Assignee David Marginian [ davidmarginian ] Team [ team ]
Hide
Mike Wilson added a comment - 12/Oct/09 3:15 PM

I think it is ok to leave as is for 3.0, but would like us to revisit this bug/feature for a later release. (It may be totally unrealistic but I am thinking that if we manage to put something smart together here, maybe we can get rid of the burden of the signatures handling)

Show
Mike Wilson added a comment - 12/Oct/09 3:15 PM I think it is ok to leave as is for 3.0, but would like us to revisit this bug/feature for a later release. (It may be totally unrealistic but I am thinking that if we manage to put something smart together here, maybe we can get rid of the burden of the signatures handling)
Hide
David Marginian added a comment - 21/Oct/09 4:34 PM

Most of the discussion related to this issue was done on the mailing list, please see:
[dwr-user] DWR does not recognize generic type parameter

Show
David Marginian added a comment - 21/Oct/09 4:34 PM Most of the discussion related to this issue was done on the mailing list, please see: [dwr-user] DWR does not recognize generic type parameter
Hide
Nicolas Bourdeau added a comment - 22/Oct/09 6:39 AM

For your information, this problem seems more related to Java than DWR :

http://forums.sun.com/thread.jspa?threadID=696289

The Introspector does not correctly retrieve type information for Subclasses of Parametrized classes ...

Show
Nicolas Bourdeau added a comment - 22/Oct/09 6:39 AM For your information, this problem seems more related to Java than DWR : http://forums.sun.com/thread.jspa?threadID=696289 The Introspector does not correctly retrieve type information for Subclasses of Parametrized classes ...
David Marginian made changes - 10/Dec/10 8:20 PM
Fix Version/s 4.0 [ 10024 ]
Fix Version/s 3.0 [ 10025 ]

People

Dates

  • Created:
    21/Sep/09 2:08 PM
    Updated:
    10/Dec/10 8:20 PM