jts icon indicating copy to clipboard operation
jts copied to clipboard

Clarify targeted Java version

Open dbaston opened this issue 8 years ago • 22 comments
trafficstars

I'm not able to find anything in the POM files or project documentation that states which version of Java is targeted by JTS. (Does Maven default to Java 5?).

dbaston avatar Sep 01 '17 01:09 dbaston

Would be nice, especially once #146 is resolved.

Perhaps Java 1.7? Not sure there's any point in staying with 1.5. I think TestBuilder needs 1.7 for finicky Swing API reasons.

dr-jts avatar Sep 01 '17 02:09 dr-jts

I think the point here isn't the merits of one version over another, it's about the pom stating the version explicitly: https://github.com/locationtech/spatial4j/blob/master/pom.xml#L172 IMO every project ought to do this explicitly (and vast majority do); it's a shame Maven doesn't make you because it's presumptuous to depend on the JVM the user is using to run Maven itself.

dsmiley avatar Sep 01 '17 13:09 dsmiley

@dsmiley Fair enough. But in order to state the version we first need to decide what the version should be.

dr-jts avatar Sep 02 '17 00:09 dr-jts

Are there actually two issues here? Which Java to use for compiling, and which versions JTS will run on? And is there a relationship between them? I.e. if we compile with 1.7 can it still run on say 1.5 or even earlier?

dr-jts avatar Oct 16 '17 21:10 dr-jts

I don't have experience targeting an earlier Java version than what I'm compiling on, but it seems like it could complicate project development and testing (developers would need to verify that standard library methods used are in fact available in the earlier versions, and that they behave equivalently, right?)

Is JTS used on platforms that do not support Java 8? (whether the project wants to use Java 8 features being another matter)

dbaston avatar Oct 17 '17 00:10 dbaston

FWIW you can just add the following properties to the parent pom:

<properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        ....

for java 8 (or 1.7 for java 7 or...), by default maven uses 1.5 because that is what the compiler plugin is defined to do.

IMHO, since the new release will also be a change in groupId I'd say it would be a safe bet to pin to 1.7 (unless you want to use closures etc..)

mprins avatar Oct 17 '17 14:10 mprins

Can we pick a source and target version for the 1.15.0 release?

jnh5y avatar Oct 28 '17 19:10 jnh5y

Generally, I'd suggest one of two options:

A. Be conservative, and pick something like 1.5. B. Note that Java 7 has been EOL'ed for over two years, and pick Java 1.8.

jnh5y avatar Oct 28 '17 19:10 jnh5y

just for the record, we use JTS for Android apps. Java 1.8 on android is pretty sketchy - some Java 1.8 classes / methods are unsupported depending on android version etc. Conservative is good for us 👍

https://developer.android.com/studio/write/java8-support.html

snodnipper avatar Jan 15 '18 11:01 snodnipper

@snodnipper Do you know anything we can use in a Maven build to verify/check that JTS would be compatible with Android? (It sounds like Android compatibility will not be captured entirely by the Maven/compiler language version targeting options.)

Overall, I'd like to see JTS be as useful as possible while at the same time letting the project leverage as many Java features as possible.

jnh5y avatar Jan 15 '18 16:01 jnh5y

@jnh5y - elegantly no. Typically, one would build with the Android gradle build tools, which have all kinds of lint checks. There is the android-maven-plugin but I haven't used that for years.

Practically, 1.7 should be fine and CI building/testing with the Android build tools would give feedback without everyone having to install the Android SDK. 1.8 syntax can be ok too but clearly there are API chunks missing for many devices - where the app would terminate.

okhttp is an example of a maven project with Android artifacts.

We use CircleCI for feedback ourselves, our search repo is an (old) example.

snodnipper avatar Jan 15 '18 17:01 snodnipper

So is the TLDR: target JTS to build on 1.7 ?

If so, that seems reasonable to me.

dr-jts avatar Jan 15 '18 21:01 dr-jts

Given that JTS now uses interface default methods (for example, here) it seems like the target is now 1.8.

dbaston avatar Aug 28 '18 01:08 dbaston

Staying at Java 1.7 would help us with Android support - see https://github.com/graphhopper/graphhopper/pull/1469

karussell avatar Nov 01 '18 11:11 karussell

Traditionally JTS has tried to stay at older Java versions to help with this very issue (and also to minimize issues in porting new Java language features).

The use of interface default methods definitely made the additions to the Coordinate code easier, though. Is there another option for this that would preserve Java 7 compatibility?

Thoughts @jodygarnett @jnh5y ?

dr-jts avatar Nov 01 '18 22:11 dr-jts

If the default interface methods are the only hang-up, I could imagine going back to pick up Java 7 support. That said, @jodygarnett and I were just at a code sprint focusing on Java 11 support for GeoServer.:)

Are there any other Java 8 features we are using?

jnh5y avatar Nov 02 '18 00:11 jnh5y

No other Java8 dependencies t that I know of.

Would keeping JTS at Java7 be a problem for Java11 support?

dr-jts avatar Nov 02 '18 00:11 dr-jts

I don't think there would be any particular issues supporting all the versions. If there are things that come up, we may be able to maintain a few versions/branches for some period of time...

jnh5y avatar Nov 02 '18 00:11 jnh5y

(I was more commenting out loud. It seems like Android and Oracle may push/pull libraries in different directions.)

jnh5y avatar Nov 02 '18 00:11 jnh5y

Would it be reasonable to specify the compile version at 1.8 in the root pom.xml for now (to fix the build failure described in #276) and then update the version to 1.7 at a later date if the associated code changes are made?

dbaston avatar Dec 26 '19 16:12 dbaston

Would it be reasonable to specify the compile version at 1.8 in the root pom.xml for now

Looks like this was done at d13f2309c3c28eb3aa0e. Probably this issue can be closed then?

dbaston avatar Dec 26 '19 16:12 dbaston

For posterity: Java 1.8 is the version JTS uses as of v 1.17. I see it in the release notes too (good). It seems to have come about accidentally but it's just as well to upgrade out of that old version.

dsmiley avatar Aug 01 '20 04:08 dsmiley