Skip to main content
Jump to: navigation, search

DTP Ganymede Resolving Discouraged Access Warnings

Back to DTP Main Page

Document Status

[8/24/07]: This document is a draft and should not be taken as offical until reviewed and approved by the DTP PMC and project leads.


As described in the DTP Ganymede Project Plan, a main goal of DTP Ganymede is to resolve as many Discouraged Access warnings in the DTP code line as possible. The reasoning and general process for doing this is outlined in the DTP Ganymede Development Guildlines. The purpose of this page is to collect specific information about how these Discouraged Access warnings will be resolved.

Current Status

A check of DTP HEAD at the beginning of August, 2007, reveals a large number of Discouraged Access warnings. We will call a Discouraged Access warning internal if the reference is within DTP itself, and external otherwise. Using this distinction, we find:

  • About 1800 internal warnings
  • About 160 external warnings

Resolution of Warnings

While there are a large number of Discouraged Access warnings, fortunately the vast majority of these are internal. Since we have decided that DTP components can freely use code among themselves, this means that most of the Discouraged Access warnings are really not a problem. Hence, we only need to find a way of indicating, in project and/or plug-in meta-data, that no Discouraged Access warning should be registered for org.eclipse.datatools.* classes using org.eclipse.datatools.* code.

Resolving Internal Discouraged Access Warnings

Ideally we'd like to make use of the x-friend directive for plug-in manifests. Rather than setting certain packages to "internal," we would specify the exceptions ("friends") to default internal visibilty. Since there are a large number of DTP plug-ins, and this number is changing over time, we would like to use a pattern here: something like x-friend=org.eclipse.datatools.* to indicate that any org.eclipse.datatools code can free use other org.eclipse.datatools code. Unfortunately, this is not possible: the x-friend directive requires listing each "friend" bundle, and hence is not a good solution for DTP.

We can, however, at least filter the Discouraged Access warnings at build time, giving us a clearer picture of warnings we should be addressing and allow us (if we wish) to choose error severity when reporting this class of warnings. Eclipse supports this type of build-time filtering, as described here.

  • Action Item (All plug-in owners): Add the access rule exception filter to all plug-ins containing internal Discouraged Access warnings.

Granted, this does not solve the problem at run time: if the OSGI loader is in "strict" mode, then package access restrictions, as expressed in the plug-ins' manifest file, will be enforced. Yet this is the best solution we have at the present time, and at least allows us to control for internal vs. external Discouraged Access warnings at build time.

Resolving External Discouraged Access Warnings

External Discouraged Access warnings are seen as more serious that internal one, since they represent DTP usage of Eclipse project code external to DTP that has not been exposed as API. As with any usage of non-API, DTP assumes technical debt and risk with each case. Simply stated, use of non-API exposes DTP, and all DTP adopters/users, to the risk of sudden (potentially serious) breakage at any time, since internal code is allowed to vary freely without public notification and review of changes.

Back to the top