facebook

Problem with Generics (XDoclet and JDK5)

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #255609 Reply

    nidget
    Member

    Hi,

    I’m using Eclipse 3.1.1 with MyEclipse 4.1.0
    I’m currently migrating a large project into Java 5.0 and I have a few (actually a lot of, as the project is really large) warnings with type safety because it wasn’t using Generics. Usually, I can fix them, but I have a problem in a specific case:

    Some of the classes of this project are EJB interfaces generated by XDoclet. The JDK 5 build is activated in the XDoclet configuration dialog.

    I have modified some methods like this one in the source of some CMP entity beans:

    public abstract java.util.Collection<AdvanceBean> getAdvanceBean();

    It should, i presume, generate this in the local home interface:

    public java.util.Collection<AdvanceLocal> getAdvanceBean();

    Or, at least, if I have this in the source of the EJB:

    public abstract java.util.Collection<Object> getAdvanceBean();

    I should get this in the generated interfaces:

    public java.util.Collection<Object> getAdvanceBean();

    [This is not perfect, but would disable the warnings.]

    However, it doesn’t work and it just skips the generics. In all cases, I have this in the generated interfaces and I get a lot of warnings because the type of the collection is not specified:

    public java.util.Collection getAdvanceBean();

    Can you help me to find a solution?

    Regards,
    Nidget.

    #255611 Reply

    nidget
    Member

    I’ve actually found a solution to eliminate the warnings, but it’s actually more a workaround than a real solution. Where the methods of the EJB interfaces are called, I add the annotation @SuppressWarnings(“unchecked”)
    It’s not clean as I have to do it in a lot of places. So, if you have something better, don’t hesitate.

    #255683 Reply

    Greg
    Member

    To my knowledge XDoclet will allow the user of java5 generics in your source files but it won’t actually generate interface code with java5 generics. Or at least Xdoclet 1.2.3 will not.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Problem with Generics (XDoclet and JDK5)

You must be logged in to post in the forum log in