has a non-API return type " My employee and I have met this warning several times recently. For t...">

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

My employee and I have met this warning several times recently. For the code below:

package com.mycompany.product.data; import com.mycompany.product.dao.GenericDAO; public abstract class EntityBean { public abstract GenericDAO<Object, Long> getDAO(); // ^^^^^^ <-- WARNING OCCURS HERE } 

a warning appears at the indicated location as

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

A Google search for “has a non-API return type” shows only instances where this message appears in the problem lists. Those. no public explanation.

What does it mean? We can create a filter of use problems in Eclipse so that the message disappears, but we do not want to do this if our use is a legitimate problem.

Thanks!

EDIT . This warning is not related to parameterization, since this getFactory() declaration also leads to the same warning:

 public abstract class EntityBean { protected DAOFactory getFactory() { return DAOFactory.instance(DAOFactory.HIBERNATE); } } 
+4
source share
2 answers

Figured it out.

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

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

+4
source

Have you looked at the following Eclipse docs: Interaction API Rules and API Errors and Warnings ?

+1
source

Source: https://habr.com/ru/post/1306150/


All Articles