Did you already try the steps I gave you in the Checker Framework
discussion list?
-Guenther
Here is my setup in Eclipse:
Projects:
Depends on your needs, whether you want to use binary releases or
source all the way, you need to have the following projects checked out:
- checkers (in checker-framework repo): The Checker Framework
repository
- jsr308-langtools or jsr308-langtools.basic (from jsr308-langtools
repositories): The compiler
- javaparser (in checker-framework repo): The java parser used to
parse stub files.
Workspace Settings:
Please set JDK6 as your default Java library. If you are using a Mac,
I recommend using soylatte JDK6 rather than Apple JDK6.
Project Setup (in order of complexity) - details of Java Build Path
- javaparser:
source: javaparser/src
output: javaparser/bin
- jsr308-langtools:
source: jsr308-langtools/src/share/classes
output: jsr308-langtools/build <-- Not perfect but oh well
- checkers:
source: checkers/src, checkers/tests/src
projects: jsr308-langtools, javaparser
libraries: checkers/lib/asmx.jar, checkers/tests/junit.jar
Order and Export: jsr308-langtools needs to be checked and higher
than 'JRE System Library [JVM 1.6]'
Running and Debugging Configuration:
Project: checkers
Main class: com.sun.tools.javac.Main
Program arguments: [whatever you want to pass to the compiler]
Classpath:
Add jsr308-langtools project to 'Bootstrap Entries' above 'JRE
System Library [JVM 1.6]'
Violla, and now your system should work almost flawlessly. I don't
think that you need to setup any any symbolic links, as has been
recommended elsewhere.
You may face a couple of issues when switching back and forth between
using Ant and Eclipse (especially related to the compiler). I usually
just do a Refresh/Clean Build, but you can just change the binary
output for the jsr308-langtools instead. Similarly, running the
checker tests is a bit tricky, and I will try to document it further
in the manual instead.
Please confirm whether or not these configurations are working for you!
Regards,
- Mahmood
In my configuration, I'm able to debug (using the Eclipse debugger) the
existing checkers with source code. I had to attach the
jsr308-langtools/dist/lib/src.zip to one of my JARs for that. As far as
I remember, there's an Ant target in jsr308-langtools to build it.
I'm also able to run the tests inside the Eclipse JUnit runner
directly. To do that, I had to create a run configuration to run JUnit
tests. In its configuration dialog, on the "arguments" tab, I added
"-Xbootclasspath/p:${workspace_loc:checkers}/langtools-dist/lib/javac.jar"
as VM argument. I also had to play a bit with the JAR file import order,
where I ended up with this:
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests/src"/>
<classpathentry kind="lib" path="checkers.jar" sourcepath="src"/>
<classpathentry kind="lib" path="lib/asmx.jar"/>
<classpathentry kind="lib" path="lib/javaparser.jar"/>
<classpathentry kind="lib" path="tests/junit.jar"/>
<classpathentry kind="lib" path="langtools-dist/lib/doclets.jar" sourcepath="langtools-dist/lib/src.zip"/>
<classpathentry kind="lib" path="langtools-dist/lib/javadoc.jar"/>
<classpathentry kind="lib" path="langtools-dist/lib/javac.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
(This is equivalent to how the JAR imports appear for me in "Project
Properties->Java Build Path->Order and Export".)
Note that langtools-dist is a symlink to jsr308-langtools/dist in my
project. I did this to avoid having hard-coded JAR-file references
checked into my SVN repositories. I know it's a hack, it's just one way
to do it. :-> Creating jsr308-langtools as a project in eclipse and
referencing the JARs across Eclipse project boundaries should work just
as fine.
Best regards,
Guenther
On Wed, Oct 21, 2009 at 02:15:06PM -0700, Ales Plsek wrote:
>
> Hello Gunter,
>
> I was reading your post. I will definitely try your approach, however,
> I am not sure if it really does what we need.
> Please, let me ask you, with the configuration of your project, are
> you able to run any "Debug Configuration" in Eclipse? I though that
> for this a complete source code is needed.
> It seems to me that the problem here is that JSR308 implementation
> needs "com.sun.tools.javac.*" packages which I can not find in the
> distribution.
>
> Well, I am just guessing, a straightforward approach could be to
> include the whole source code of JSR308 in a project and afterwards
> have a Debug configuration starting by calling
> "com.sun.tools.javac.Main.main" where you could supply all input
> parameters... (your checker, the .java files to be checked, etc.).
>
> Best,
> Ales
>