Pergunta

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

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top