Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse warning: "<methodName> has non-API return type <parameterizedType>"

My co-worker and I have come across this warning message a couple times recently. For the below code:

package com.mycompany.product.data;

import com.mycompany.product.dao.GenericDAO;

public abstract class EntityBean {
    public abstract GenericDAO<Object, Long> getDAO();
    //                                       ^^^^^^      <-- WARNING OCCURS HERE
}

the warning appears in the listed spot as

EntityBean.getDAO() has non-API return type GenericDAO<T, ID>

A Google search for "has non-API return type" only shows instances where this message appears in problem lists. I.e., there's no public explanation for it.

What does this mean? We can create a usage problem filter in Eclipse to make the message go away, but we don't want to do this if our usage is a legitimate problem.

Thanks!

EDIT: This warning doesn't have to do with the parameterization, as this declaration of getFactory() also results in the same warning:

public abstract class EntityBean {
    protected DAOFactory getFactory() {
        return DAOFactory.instance(DAOFactory.HIBERNATE);
    }
}
like image 210
James Cronen Avatar asked Apr 06 '10 17:04

James Cronen


1 Answers

Figured it out.

These classes (GenericDAO and DAOFactory as return types) and EntityBean were in different packages. One of the packages (the one containing EntityBean) was listed in the Export-Package: section of the manifest file, and the other package (DAOs) was not. The net effect is that the DAO classes were non-API and were being returned by an API type.

Thanks all, especially to JRL for orienting me in the right direction.

like image 162
James Cronen Avatar answered Sep 23 '22 01:09

James Cronen