Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error creating boundbox of class with a generic method #23

Open
kirwan opened this issue Mar 17, 2014 · 1 comment
Open

Error creating boundbox of class with a generic method #23

kirwan opened this issue Mar 17, 2014 · 1 comment

Comments

@kirwan
Copy link

kirwan commented Mar 17, 2014

When trying to create a BoundBox of a class with a generic method, the created class doesn't compile due to failing to pick up the details of the generic element.

The method in question looks like this:

public <E extends FeedContent> E copyInto(E copy) {
  // do stuff
  return copy;
}

But the equivalent method in the BoundBox looks like this:

public E copyIntoNewContent(E arg0) {
  try {
    Method methodToInvoke = com.mycompany.MyClass.class.getDeclaredMethod("copyInto",E.class);
    methodToInvoke.setAccessible(true);
    return (E)  methodToInvoke.invoke(boundObject,arg0);
  }
  catch( IllegalAccessException e ) {
    throw new BoundBoxException(e);
  }
  catch( IllegalArgumentException e ) {
    throw new BoundBoxException(e);
  }
  catch( InvocationTargetException e ) {
    throw new BoundBoxException(e);
  }
  catch( NoSuchMethodException e ) {
    throw new BoundBoxException(e);
  }
}

This results in an error because E cannot be resolved to a type.

@WonderCsabo
Copy link

This is a serious issue. In AndroidAnnotations we handled this problem, see this PR. Note that AA uses CodeModel for code generation, which is much more sophisticated then JavaWriter.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants