Tapestry
  1. Tapestry
  2. TAPESTRY-1410

fail to test GenericsMethodSignatureImpl class.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.1.2
    • Component/s: Core Components
    • Labels:
      None
    • Environment:
      jdk1.5

      Description

      fail to test GenericsMethodSignatureImpl class.

      public class GenericsMethodSignatureImplTest {

      public static abstract class BaseTest<T>{

      }
      public static abstract class MyTest<T,E>extends BaseTest<T>

      { public abstract E getRelativeObject(); public abstract void setRelativeObject(E e); }

      @Test
      public void test_generic() {
      Class testClass=MyTest.class;
      Method[] methods = testClass.getMethods();
      for (Method method : methods)

      { MethodSignatureImpl msi = new GenericsMethodSignatureImpl(testClass,method); msi.hashCode(); }

      }

      }

        Activity

        Hide
        Jesse Kuhnert added a comment -

        Thanks for the report ! (and sorry for the bug)

        Show
        Jesse Kuhnert added a comment - Thanks for the report ! (and sorry for the bug)
        Hide
        Jun Tsai added a comment -

        I think the generic return type is not void.It should be E or Object.

        Show
        Jun Tsai added a comment - I think the generic return type is not void.It should be E or Object.
        Hide
        Jun Tsai added a comment -

        Code is

        public abstract E getRelativeObject();
        public abstract void setRelativeObject(E e);

        Exception:

        Method 'public abstract java.lang.Object corner.orm.tapestry.page.relative.AbstractManyEntityFormPage.getRelativeObject()' (declared in class corner.orm.tapestry.page.relative.AbstractManyEntityFormPage) has no implementation in class com.bjmaxinfo.piano.page.CompanywareFormPage (or enhanced subclass $CompanywareFormPage_96).

        Show
        Jun Tsai added a comment - Code is public abstract E getRelativeObject(); public abstract void setRelativeObject(E e); Exception: Method 'public abstract java.lang.Object corner.orm.tapestry.page.relative.AbstractManyEntityFormPage.getRelativeObject()' (declared in class corner.orm.tapestry.page.relative.AbstractManyEntityFormPage) has no implementation in class com.bjmaxinfo.piano.page.CompanywareFormPage (or enhanced subclass $CompanywareFormPage_96).
        Hide
        Jun Tsai added a comment -

        The new test is fail.

        public class GenericsMethodSignatureImplTest extends Assert{
        public static abstract class BaseTest<T> {

        }

        public static abstract class MyTest<T, E> extends BaseTest<T>

        { public abstract E getRelativeObject(); public abstract void setRelativeObject(E e); }

        @Test
        public void test_generic() {
        Class testClass = MyTest.class;
        Method[] methods = testClass.getMethods();
        for (Method method : methods) {
        MethodSignatureImpl msi = new GenericsMethodSignatureImpl(
        testClass, method);
        if(method.getName().equals("getRelativeObject"))

        { assertEquals(msi.getReturnType(),"java.lang.Object"); //get return type shuld be object }

        }
        }

        }

        Show
        Jun Tsai added a comment - The new test is fail. public class GenericsMethodSignatureImplTest extends Assert{ public static abstract class BaseTest<T> { } public static abstract class MyTest<T, E> extends BaseTest<T> { public abstract E getRelativeObject(); public abstract void setRelativeObject(E e); } @Test public void test_generic() { Class testClass = MyTest.class; Method[] methods = testClass.getMethods(); for (Method method : methods) { MethodSignatureImpl msi = new GenericsMethodSignatureImpl( testClass, method); if(method.getName().equals("getRelativeObject")) { assertEquals(msi.getReturnType(),"java.lang.Object"); //get return type shuld be object } } } }
        Hide
        Jun Tsai added a comment -

        assertEquals(msi.getReturnType(),"java.lang.Object"); //get return type shuld be object

        is wrong.

        should be:

        assertEquals(msi.getReturnType(),Object.class); //get return type shuld be object

        Show
        Jun Tsai added a comment - assertEquals(msi.getReturnType(),"java.lang.Object"); //get return type shuld be object is wrong. should be: assertEquals(msi.getReturnType(),Object.class); //get return type shuld be object
        Hide
        Jun Tsai added a comment -

        public class GenericsMethodSignatureImplTest extends Assert {
        public static abstract class BaseTest<T> {

        }

        public static abstract class MyTest<T, E extends BaseTest<T>> extends BaseTest<T>

        { public abstract E getRelativeObject(); public abstract void setRelativeObject(E e); }

        @Test
        public void test_generic() {
        Class testClass = MyTest.class;
        Method[] methods = testClass.getMethods();
        for (Method method : methods) {
        MethodSignatureImpl msi = new GenericsMethodSignatureImpl(
        testClass, method);
        if (method.getName().equals("getRelativeObject"))

        { assertEquals(msi.getReturnType(), Object.class); }

        }
        }
        }

        fail to run the test.

        EXCEPTION:

        java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
        at org.apache.tapestry.enhance.GenericsMethodSignatureImpl.findReturnType(GenericsMethodSignatureImpl.java:57)
        at org.apache.tapestry.enhance.GenericsMethodSignatureImpl.<init>(GenericsMethodSignatureImpl.java:32)

        Show
        Jun Tsai added a comment - public class GenericsMethodSignatureImplTest extends Assert { public static abstract class BaseTest<T> { } public static abstract class MyTest<T, E extends BaseTest<T>> extends BaseTest<T> { public abstract E getRelativeObject(); public abstract void setRelativeObject(E e); } @Test public void test_generic() { Class testClass = MyTest.class; Method[] methods = testClass.getMethods(); for (Method method : methods) { MethodSignatureImpl msi = new GenericsMethodSignatureImpl( testClass, method); if (method.getName().equals("getRelativeObject")) { assertEquals(msi.getReturnType(), Object.class); } } } } fail to run the test. EXCEPTION: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl at org.apache.tapestry.enhance.GenericsMethodSignatureImpl.findReturnType(GenericsMethodSignatureImpl.java:57) at org.apache.tapestry.enhance.GenericsMethodSignatureImpl.<init>(GenericsMethodSignatureImpl.java:32)
        Hide
        Jesse Kuhnert added a comment -

        Ok I can confirm the failure, but in your example the return type is not Object since you have "E" bound to extend BaseTest<T> ...So BaseTest<T> is the actual type that will be returned.

        Show
        Jesse Kuhnert added a comment - Ok I can confirm the failure, but in your example the return type is not Object since you have "E" bound to extend BaseTest<T> ...So BaseTest<T> is the actual type that will be returned.
        Hide
        Jesse Kuhnert added a comment -

        Ok, should be all set now.

        Show
        Jesse Kuhnert added a comment - Ok, should be all set now.

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Jun Tsai
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development