Dear reader of Juri's TechBlog,
I moved my blog to a new domain and a new hosting solution as well. I'm now blogging on juristr.com.

The type X is not accessible due to restriction on the...

For some university course we currently have to modify an Open Source application with LOC > 50,000. So due to our particular interest in Eclipse RCP development, our team has chosen the RSSOwl, a smart Newsfeed reader which is based on Eclipse RCP (you should check it out).
After downloading the latest source from the code repository, the build seemed to be broken since it reported about 18 errors saying something like:

The type [X] is not accessible due to restriction on required library [Y].
...where [X] and [Y] are of course placeholders for the class and jar library :) . After some (actually long) search on the web, one of my collegues found the "solution" for the problem. It was actually a wrong Eclipse configuration of the Java compiler. What has to be done is to set the "Forbidden reference (access rules)" under the "Deprecated and restricted API" from "Error" to "Warning".

In this way Eclipse will treat the problem as a warning instead of an error. I discussed that configuration with the RSSOwl author and he affirmed me that it is fine to have the configuration set to "warning".

Posts you might also be interested in..

Credits: Hoctro | Jack Book

21 Comments:

selvan said...

Thanks so much. After so many hours, I found the solution.
thanks again

Anonymous said...

Thanks, that was indeed very useful :)

Anonymous said...

thanks!

Anonymous said...

thanks a lot.
this realy helped

levi said...

Thanks, Juri. That saved me a lot of time.

Anonymous said...

thanks alot! :)

Anonymous said...

Thanks a lot this helped me.....

sayeed said...

thanks for the info. really a big time saver...

Anonymous said...

Спасибо большое, очень помогло!

Anonymous said...

Thanks a lot!

Anonymous said...

Thanks, I was hours searching for this!!!!!

Paulo said...

Alright, but why does it happen?

Rahul Jha said...

Thanks a lot for this solution!

Anonymous said...

It helped me :-) Thanks

Anonymous said...

thanks so much ... I would have never thought it was an eclipse problem and would have tried everything else first ... so thanks for saving me a lot of wasted time!

Anonymous said...

if you "add external jars" at project setup there will be no errors or warnings and will run fine.
just press "add external jars" and navigate to programfiles(*86), java, jre6, lib, ext, select all contents and click open and finish the project. Cant be to hard because I figured it out all by myself and I am only 14 and on my first year of java.

Anonymous said...

Thank you for the solution...

Nidhi said...

Thanks for the solution! you rock! :)

Anonymous said...

Thanks a lot.

Anonymous said...

Thanks a lot! It worked for me :)

Anonymous said...

Thanks for that. Quickly soleved an annoying problem.

@14yo Anonymous: If I understand your way correct, you are importing java files into your project. Of course the restrictions will disappear then (since the jars are in your project).
But you will deliver some java files with your solution, which might have weired effects if someone starts your application using another java version.

So there is no need to be overconfident.

Post a Comment