John Smith
John Smith

Reputation: 787

Discouraged access Eclipse library

I get the following warnings on two of my libraries :

at

import org.eclipse.ui.internal.Workbench;

Discouraged acces: The type Workbench is not accessible due to restriction on required library org.eclipse.ui.workbench_3.8.0

at

import org.eclipse.jdt.internal.core.PackageFragmentRoot;

Discouraged acces: The type PackageFragmentRoot is not accessible due to restriction on required library org.eclipse.jdt.core_3.8.1

What can be the cause for this and how can I solve this problem ?

Upvotes: 0

Views: 2053

Answers (1)

Fredrik
Fredrik

Reputation: 10646

You are getting these errors because you are importing packages that are marked internal;

import org.eclipse.ui.**internal**.Workbench

This is an indication that they are not intended to be used from the outside, implementation could drastically change without any notice which could cause your application to fail. If the functionality is intended to be usable for others, there will typically be an publiclly available api you can use instead.

Your options are;

  • See if there is a better package to use which is intended for outside usage.
  • Ignore the warnings and continue to use them anyway.

Normally I would strongly encourage option 1 and not even suggest option 2, but Eclipse can be a bit strange with how they define their internal packages sometimes. I have on serveral occasions been forced to use internal packages.

In your situation it looks like org.eclipse.ui.IWorkbench and org.eclipse.jdt.core.IPackageFragmentRoot should be a better fit.

Upvotes: 2

Related Questions