Skip to Content

compiler options in pde build are not recognized

Posted in

Hi,

the code:

package de.soffel.hellorcp;
import javax.smartcardio.CommandAPDU;
public class Test3 {
}

compiles fine under eclipse, if one enables project specific settings for compiler errors and warnings.
There the "Forbidden reference (access rules)" setting needs to be changed/relaxed at least to "Warning".

My preferred way to solve this, is to define an access rule for that. But ant4eclipse is not supporting this
at the moment, see http://www.ant4eclipse.org/node/120 and http://www.javakontor.org:8080/jira/browse/AE-64.

Compiling this code, which is part of a plugin, with ant4eclipse using a4e-pde-macros.xml fails with the following error:

[ant4eclipse:jdtCompiler] ----------
[ant4eclipse:jdtCompiler] 1. ERROR in D:\workspaces\a4e_hellorcp\de.soffel.hellorcp\src\de\soffel\hellorcp\Test3.java (at line 2)
[ant4eclipse:jdtCompiler] import javax.smartcardio.CommandAPDU;
[ant4eclipse:jdtCompiler]        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ant4eclipse:jdtCompiler] Access restriction: The type CommandAPDU is not accessible due to restriction on required library C:\Programme\Java\jdk1.6.0_18\jre\lib\rt.jar
[ant4eclipse:jdtCompiler] ----------

From the code in a4e-pde-macros.xml these project specific settings should be recognized. If I use the "defaultCompilerOptionsFile" setting option, it does not work either.
Strange: It compiles with ant4eclipse under win, if I comment out the following code in a4e-pde-macros.xml:

                <compilerarg value="compiler.args.refid=buildPlugin.compiler.args"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />

But this works only under win and not under linux. Right now, I am not sure, what I am doing here by commenting this line out.
Some hints on the purpose of this line are welcome.

Now, is this a bug? Shall I open a jira? It would be a great help for our project, to get a solution to this problem.
Right now I have no clue, on how to get around this.

Thanks for your work on a4e and best regards,

Georg.

PS: I am using build 1898 of a4e.

Use a JRE instead of an execution environment

If you comment out the EcjCompilerAdapter a4e will use the javac instead of the eclipse compiler. Since the javac doesn't support access restriction, the code compiles without warnings/errors.

The problem you have is the following:

1) I assume that you have chosen the JavaSE-1.6 execution environment in your project 'de.soffel.hellorcp'

2) The JavaSE-1.6 profile does NOT contain the 'javax.smartcardio' package. So it is not a bug, it's the intended behaviour that you get build breaker

3) If you want to access the package, you can either define your own exection environment OR simply change the JRE setting for your project so that you use a JRE instead of an execution environment (right-click on JRE System Library in your project, than choose 'properties').

Hope it helps...

Regards,
Gerd

Hi Gerd, thanks for the quick

Hi Gerd,

thanks for the quick answer and the help.

Form the lines in a4e-pde-macros.xml:

                <!-- we have to pass in the reference to the additional compiler arguments  -->
                <compilerarg value="compiler.args.refid=buildPlugin.compiler.args"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />
 
                <!-- we also have to pass path of the compiler options file to support project specific compiler options -->
                <compilerarg value="compiler.options.file=${buildPlugin.project.directory}/.settings/org.eclipse.jdt.core.prefs"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />
 
                <!-- pass the path of the default compiler options file -->
                <compilerarg value="default.compiler.options.file=@{defaultCompilerOptionsFile}"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />

I only commented out the first element. This yields to:
                <!-- we have to pass in the reference to the additional compiler arguments
                <compilerarg value="compiler.args.refid=buildPlugin.compiler.args"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />
                  -->
 
                <!-- we also have to pass path of the compiler options file to support project specific compiler options -->
                <compilerarg value="compiler.options.file=${buildPlugin.project.directory}/.settings/org.eclipse.jdt.core.prefs"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />
 
                <!-- pass the path of the default compiler options file -->
                <compilerarg value="default.compiler.options.file=@{defaultCompilerOptionsFile}"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />

Does this mean I use javac instead of the eclipse compiler?
An what does the element
                <compilerarg value="compiler.args.refid=buildPlugin.compiler.args"
                             compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />

exactly do?

And then my question is still not answered: If I do not touch the a4e-pde-macros.xml, the project specific settings for compiler errors and warnings are not taken into account.
There is the file "d:\workspaces\a4e_hellorcp\de.soffel.hellorcp\.settings\org.eclipse.jdt.core.prefs" which seams not to be recognized, especially the line:

org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning

I think, there is still a problem with ant4eclipse PDE build and compiler options.

Thx and best regards,

Georg

Bug AE-220

Internally ant4eclipse uses a data structure that is used to provide additional information for the (ejc) compiler adapter. Unfortunately thinks like access restrictions can't be specified using the standard ant javac task.

The line
compiler="org.ant4eclipse.ant.jdt.ecj.EcjCompilerAdapter" />
passes over the internal datastructure to the EcjCompilerAdapter. If you comment out this line, things like access restrictions are not longer available to the EcjCompilerAdapter. Please dont' comment out this line!

I check the issue with the 'forbiddenReference'. For some (unknown) reason we explicitly set this option to 'error' in ant4eclipse. That's indeed a bug, and I opened an issue for that one: http://www.javakontor.org:8080/jira/browse/AE-220

Thanks for reporting!

Regards,
Gerd