0

I'm writing a general purpose library (let's say junit or spring). I don't use any features of newer java versions. i want to put my library in maven central.

my question is: what -target should i chose during compilation? if i chose 1.2 then everyone will be able to use my library, however i'm not sure if i loose some performance when running on recent jvm. what are best practises in such cases? i want to avoid deploying many versions in maven central, each for specific jvm

gigadot
  • 8,879
  • 7
  • 35
  • 51
piotrek
  • 13,982
  • 13
  • 79
  • 165
  • Note that simply using the target option doesn't make sure your library will run on an earlier version of the JVM as it doesn't check the availability of the APIs. Best to use the JDK version you want to support. Otherwise search for corss-compilation to get more info. – Puce Sep 28 '12 at 14:19

2 Answers2

0

I wouldn't go below 1.5 (because of generics, they might be necessary one day even if you don't use them now - see what happened with Apache Commons). And if it's a new library I think supporting the last two major Java releases is enough. But your question was more related to performance. I think the target version should not have any significant impact.

Adam Dyga
  • 8,666
  • 4
  • 27
  • 35
0

I think it should be fine to use the minimum Java version you need to compile your classes. So if your code compiles with Java 1.2 (which means you don't use any generics, enums, automatic resource management etc.) then feel free to compile it with Java 1.2.

I don't think there are huge performance blockers, altough newer javac versions might optimize code a bit better.

Puce
  • 37,247
  • 13
  • 80
  • 152