Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "discouraged reference" mean in Java?

Tags:

java

eclipse

I noticed this setting in Eclipse's compiler settings. How is this different than a "forbidden reference"?

like image 305
Eric the Red Avatar asked Jun 17 '26 10:06

Eric the Red


2 Answers

From a comment on the accepted answer on how to open the find type dialog programmatically in eclipse

You get a discouraged access warning whenever you reference a type in a package that is not part of the API, typically these are *.internal packages. "Discouraged access" is an indicator that you should look for an API alternative if possible. Be aware that you might be vulnerable to change in later versions of Eclipse. See help.eclipse.org/galileo/index.jsp for more details – Rich Seller

like image 111
Lucas Zamboulis Avatar answered Jun 20 '26 00:06

Lucas Zamboulis


Eclipse has Internal packages that are not intended for use by downstream plug-ins. However, these packages are visible to downstream plug-ins by default.

A discouraged reference is a reference in your code to one of the Eclipse internal packages.

You can find more information in the Plug-in Development Environment Guide -> Tools -> Editors -> Plug-in manifest editor -> Plug-in run time -> Access Rules.

like image 45
Gilbert Le Blanc Avatar answered Jun 19 '26 22:06

Gilbert Le Blanc