{"id":454,"date":"2012-09-20T20:15:17","date_gmt":"2012-09-20T14:45:17","guid":{"rendered":"http:\/\/ramkulkarni.com\/blog\/?p=454"},"modified":"2012-09-20T20:15:17","modified_gmt":"2012-09-20T14:45:17","slug":"access-restriction-error-in-eclipse-plugins","status":"publish","type":"post","link":"http:\/\/ramkulkarni.com\/blog\/access-restriction-error-in-eclipse-plugins\/","title":{"rendered":"&quot;Access restriction&quot; error in Eclipse plugins"},"content":{"rendered":"<p>I spent quite a lot of time today trying to debug &#8220;Access restriction&#8221; error in one of my Eclipse plugins. In the last four years of Eclipse plugin development, I don&#8217;t recall ever facing this issue, but today suddenly some of the imports in one of the classes in my Eclipse plugin were flagged off as errors &#8211;<\/p>\n<p style=\"color: red;\">Access restriction: The type ISelection is not accessible due to restriction on required library &lt;eclipse-path&gt;\\eclipse\\plugins\\org.eclipse.jface_3.6.1.M20100825-0800.jar<\/p>\n<p>I had seen warnings about &#8216;restricted access&#8217; for some of the imports earlier, but those were for classes that Eclipse discouraged to use e,g, for internal Eclipse classes. But today I was seeing errors.<\/p>\n<p>The error does not tell much about what could have gone wrong. ISelection is exported from jface plugin and it is a public interface. And I had used this class without any error in other plugins.<\/p>\n<p><!--more--><\/p>\n<p>A quick search on the net and I found a couple of suggestions &#8211; one most common suggestion was to remove and add JRE lib again from the project build properties (in Project Properties-&gt;Java Build Path-&gt;Libraries). Though the solution was suggested for the same error, the class in the error was JDK built-in class, so I guess this suggestion might work for such cases.<\/p>\n<p>Another solution was to turn-off this error. You can do so by going to Preferences-&gt;Java-&gt;Compiler-&gt;Errors\/Warnings\/Deprecated and restricted API-&gt;Forbidden reference (access rule) and changing its value from &#8216;Error&#8217; to &#8216;Warning&#8217;. I did this and the error was gone and was replaced by warning. I executed my application and this warning did not seem to cause any problem.<\/p>\n<p>However I was curious to find solution for this and did not want to see warnings too. It was obvious that the error was related to plugins I had listed in dependencies (required plugins for my plugin). I removed all dependencies and added them back in different order. To my surprise, this fixed the problem. I had required plugins in following order in my MANIFEST.MF &#8211;<\/p>\n<p>Require-Bundle: org.eclipse.core.runtime,<br \/>\norg.eclipse.debug.core,<br \/>\nmy-plugin1,<br \/>\nmy.plugin2,<br \/>\nmy.plugin2,<br \/>\norg.eclipse.ui<\/p>\n<p>I changed this to &#8211;<\/p>\n<p>Require-Bundle: my.plugin1,<br \/>\nmy.plugin2,<br \/>\norg.eclipse.debug.core,<br \/>\norg.eclipse.core.runtime,<br \/>\norg.eclipse.ui,<br \/>\nmy.plugin3<\/p>\n<p>I don&#8217;t know how to figure out the correct order for required plugins. As far as I know, OSGi does not require you to specify required bundles in any particular order. So this could be a limitation of Eclipse implementation.<\/p>\n<p>-Ram Kulkarni<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spent quite a lot of time today trying to debug &#8220;Access restriction&#8221; error in one of my Eclipse plugins. In the last four years of Eclipse plugin development, I don&#8217;t recall ever facing this issue, but today suddenly some of the imports in one of the classes in my Eclipse plugin were flagged off &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/ramkulkarni.com\/blog\/access-restriction-error-in-eclipse-plugins\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;&quot;Access restriction&quot; error in Eclipse plugins&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[38,1],"tags":[50,25],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2g9O8-7k","jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/posts\/454"}],"collection":[{"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/comments?post=454"}],"version-history":[{"count":0,"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/posts\/454\/revisions"}],"wp:attachment":[{"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/media?parent=454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/categories?post=454"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ramkulkarni.com\/blog\/wp-json\/wp\/v2\/tags?post=454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}