This is the generics guide for Aurora. For Pallada (IDEA 4.1) look at GenericsFAQ
Here is a simple How To Guide to get started with java generics. Please feel free to make any corrections or additions that you think are necessary to make the transition easier.
- Download the Early Access JSR14 prototype from here
- Extract it anywhere. We will call JSR14_HOME that directory
- As of 2.4, you need to copy the classes of gjc-rt.jar into collect.jar
- Copy JSR14_HOME/collect.jar and JSR14_HOME/gjc-rt.jar to IDEA_HOME/lib/generics (you have to create the directory)
Alternatively use the wizard in IDEA for that. It can be found in the menu Tools/Set Up JSR014 Implementation. However don't forget to do step 3.
Set up an IDEA project
- Open the Project Properties
- Select the Main Module properties
- In the Library tab add IDEA_HOME/lib/generics/collect.jar

- In the Order tab, put collect.jar first (before the JDK)

- Select the Compiler properties
- Select the option Use generics-enabled compiler

- Restart IDEA
Using JSR Adapter for compiling
- Add a property named
jsr14.home that points to JSR14_HOME<property name="jsr14.home" value="<<JSR14_HOME>>"/>
- Add
collect.jar in first in any compilation classpath
- Download the compiler adapter generously donated by Cortex eBusiness (maker of clover one of the greatest java coverage tool) here or use the cached version here and save it either in your project or your ant install
- Add
jsr14adapter-1.2.jar to your Ant classpath. In IDEA:
- Go to the Ant tool window/Properties

- Add
jsr14adapter-1.2.jar to the Additional Classpath

- Change your
javac target to add the following attributes
<javac destdir="${dir.build.classes}"
source="1.5"
compiler="com.cortexeb.Jsr14CompilerAdapter"
srcdir="${dir.plugin.util.src}:${dir.src}:${dir.additional.src}">
<classpath refid="compile.classpath"/>
</javac>
- Add this to your junit task
<junit fork="yes">
...
<jvmarg value="-Xbootclasspath/p:${jsr14.home}/gjc-rt.jar"/>
</junit>
- You are set
Using standard javac ANT task for compiling
You can compile generics code by javac ANT task:
<javac
fork="yes"
includejavaruntime="yes"
destdir="${project.classes}"
bootclasspath="${generics.home}/collect.jar"
classpathref="project.classpath"
debug="on"
source="1.5"
>
<compilerarg value="-J-Xbootclasspath/p:${generics.home}/gjc-rt.jar"/>
<src path="${project.src}"/>
<include name="**/*.java"/>
</javac>
Using sinjdoc tool for JavaDoc generation
You must have sinjdoc installed.
For generation javadocs you may use follow script:
<fileset dir="${project.src}" id="project.src.java">
<include name="**/*.java" />
</fileset>
<pathconvert pathsep=" " property="project.src.files" refid="project.src.java"/>
<java jar="${sinjdoc.home}/sinjdoc.jar" fork="true">
<jvmarg line="-Xbootclasspath/p:${generics.home}/gjc-rt.jar"/>
<classpath refid="project.classpath" />
<arg value="-protected" />
<arg value="-author" />
<arg value="-version" />
<arg value="-use" />
<arg value="-source" />
<arg value="1.5" />
<arg value="-d" />
<arg value="${project.build}/${project.name}/docs/api" />
<arg value="-sourcepath" />
<arg value="${project.src}" />
<arg line="${project.src.files}" />
</java>
See http://www.intellij.net/tracker/idea/viewSCR?publicId=14522 for more detail.