Compiling with generics

I've got a mixed JDK project - some modules use 1.4, and some use 1.5. In my 1.5 code, I've started using generics.
(I'm using IDEA build 2013).

Basically, I've now got problems being able to compile both 1.4 and 1.5 source.

In order to compile with generics, I added "-source 1.5" to the compiler command line parameters.
This works fine when compiling 1.5 files.
However, if 1.4 files are to be compiled, I get an error "javac: invalid source release 1.5". This is understandable - the 1.4. compiler doesn't understand 1.5 source.

So it's a bit ackward to get my code to compile - I need the extra parameter for 1.5, but this causes 1.4 to not work.
Does anyone have any suggestions for the best way round this?
Currently, I'm mainly working on 1.5 files. So I temporarily removed the command line parameter, compiled my 1.4 files, added the parameter back in and compiled my 1.5 files. This isn't too bad, as my 1.4 files aren't changing too much.


I think the root of the problem is that there's only a single place where you can add compiler command line parameters - you've got to have the same parameters for all different JDKs. So maybe this should be divided up per JDK - or even per module.


Also, I tried the "Use generics-enabled compiler" in the Compiler settings. I'm not 100% sure what this is supposed to do, but it brought up an error dialog "Compiler Class Not Found", "<idea-installation-folder>\lib\generics\collect.jar not found".

6 comments
Comment actions Permalink


"Calum MacLean" <no_mail@jetbrains.com> wrote in message news:7872783.1083771490044.JavaMail.itn@is.intellij.net...

I've got a mixed JDK project - some modules use 1.4, and some use 1.5. In my 1.5 code, I've started using generics.
(I'm using IDEA build 2013).

>

Basically, I've now got problems being able to compile both 1.4 and 1.5 source.

>

In order to compile with generics, I added "-source 1.5" to the compiler command line parameters.
This works fine when compiling 1.5 files.
However, if 1.4 files are to be compiled, I get an error "javac: invalid source release 1.5". This is understandable - the 1.4.

compiler doesn't understand 1.5 source.
>

So it's a bit ackward to get my code to compile - I need the extra parameter for 1.5, but this causes 1.4 to not work.
Does anyone have any suggestions for the best way round this?
Currently, I'm mainly working on 1.5 files. So I temporarily removed the command line parameter, compiled my 1.4 files, added the

parameter back in and compiled my 1.5 files. This isn't too bad, as my 1.4 files aren't changing too much.
>
>

I think the root of the problem is that there's only a single place where you can add compiler command line parameters - you've

got to have the same parameters for all different JDKs. So maybe this should be divided up per JDK - or even per module.
>
>

Also, I tried the "Use generics-enabled compiler" in the Compiler settings. I'm not 100% sure what this is supposed to do, but it

brought up an error dialog "Compiler Class Not Found", "<idea-installation-folder>\lib\generics\collect.jar not found".


0
Comment actions Permalink

Sorry for the previous "empty" post.
You are right about the awkwardness of the current settings. We are going to replale these "Enable Assert keyword" and "Enable jdk
1.5 features" checkboxes with a single per-project setting "Language level" which will be honored if applicable. For example, if you
set it to "jdk 1.4 - assert keyword" it will be honored for all modules that use jdk 1.4 and higher and ignored for all modules that
use jdk 1.3.
The same behaviour will be for the option "use generic compiler": it will be honored only for the modules that use jdk 1.4.
As for the "Compiler Class Not Found" error, use "Tools | Set Up JSR014 implementation" wizard to download generics-aware compiler.

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"



"Calum MacLean" <no_mail@jetbrains.com> wrote in message news:7872783.1083771490044.JavaMail.itn@is.intellij.net...

I've got a mixed JDK project - some modules use 1.4, and some use 1.5. In my 1.5 code, I've started using generics.
(I'm using IDEA build 2013).

>

Basically, I've now got problems being able to compile both 1.4 and 1.5 source.

>

In order to compile with generics, I added "-source 1.5" to the compiler command line parameters.
This works fine when compiling 1.5 files.
However, if 1.4 files are to be compiled, I get an error "javac: invalid source release 1.5". This is understandable - the 1.4.

compiler doesn't understand 1.5 source.
>

So it's a bit ackward to get my code to compile - I need the extra parameter for 1.5, but this causes 1.4 to not work.
Does anyone have any suggestions for the best way round this?
Currently, I'm mainly working on 1.5 files. So I temporarily removed the command line parameter, compiled my 1.4 files, added the

parameter back in and compiled my 1.5 files. This isn't too bad, as my 1.4 files aren't changing too much.
>
>

I think the root of the problem is that there's only a single place where you can add compiler command line parameters - you've

got to have the same parameters for all different JDKs. So maybe this should be divided up per JDK - or even per module.
>
>

Also, I tried the "Use generics-enabled compiler" in the Compiler settings. I'm not 100% sure what this is supposed to do, but it

brought up an error dialog "Compiler Class Not Found", "<idea-installation-folder>\lib\generics\collect.jar not found".


0
Comment actions Permalink

Eugene Zhuravlev (JetBrains) wrote:

Sorry for the previous "empty" post.
You are right about the awkwardness of the current settings. We are going to replale these "Enable Assert keyword" and "Enable jdk
1.5 features" checkboxes with a single per-project setting "Language level" which will be honored if applicable. For example, if you
set it to "jdk 1.4 - assert keyword" it will be honored for all modules that use jdk 1.4 and higher and ignored for all modules that
use jdk 1.3.


That seems overly complicated to me. Why not just allow specific options
to be enabled/disabled on a per-module basis?

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0
Comment actions Permalink

That seems overly complicated to me. Why not just allow specific options
to be enabled/disabled on a per-module basis?


This is how it will actually work. But you will have to set them once and not for each module.

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

Eugene Zhuravlev (JetBrains) wrote:

>>That seems overly complicated to me. Why not just allow specific options
>>to be enabled/disabled on a per-module basis?


This is how it will actually work. But you will have to set them once and not for each module.


But that doesn't make sense to me. Conceivably, one could have a project
which contains 2 modules, one which compiles with JDK 1.5 and uses
generics, and another which uses JDK 1.3. There is no common
"language-level" between these 2 modules other than that it's Java. Why
have a project-level language-level setting which one then has to
perform mental XORing with the actual JDK's capabilities for a
particular module to figure out what settings are going to be applied to
its source code? I would much rather be able to specify exactly what
settings are to be used with each module.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919

0

Please sign in to leave a comment.