I am using Buildship (version 2.0.1) to import a Gradle (version 3.4.1) project into Eclipse (version 4.6.2). The generated project produces compilation errors like this:
Access restriction: The constructor 'CachedRowSetImpl()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/rt.jar')...
I understand the error message. Changing the code to not use the non-API methods would be the preferred way to make the problem go away, but I cannot change the code.
I noticed something peculiar about this situation. The generated .classpath file has this entry:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
When I manually edit that line to remove the part of the path string starting with the first /: so that it looks like this:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
the Access restriction errors disappear!
Does anybody know why removing the tail part of the path makes the errors disappear?
How do I fix this problem in the context of importing the project using Buildship?
I have seen two solutions suggested to this problem of Access restriction errors. One suggests removing the entry and adding it back in. The other suggests adjusting the Access rules. I don’t think I can use those solutions in this context.