Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use java 7 syntax to compile to java 5

is there any way to use java 7 syntax and produce bytecode that works on 1.5? as far as i know, options -target and -source can't be different. checking if no new API was used also would be nice but is not crucial

like image 862
piotrek Avatar asked Mar 06 '26 09:03

piotrek


2 Answers

No, it is not. As far as I know, different -source and -target work, but only if the source is lower or equal the target (in order to provide backwards compatibility). There may be source converters that convert your java 7 code into older versions.

like image 84
thobens Avatar answered Mar 08 '26 21:03

thobens


There's a project called Retroweaver which allows you to write Java 5 syntax (including generics, etc.) and convert it to code that runs on Java 1.4 and older.

As far as I know there isn't anything like that to make code with Java 7 syntax work on older versions.

like image 25
Jesper Avatar answered Mar 08 '26 21:03

Jesper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!