Opened 4 years ago

Closed 4 years ago

#1669 closed defect (fixed)

Java 7

Reported by: zzz Owned by: zzz
Priority: minor Milestone: 0.9.24
Component: router/general Version: 0.9.22
Keywords: Cc:
Parent Tickets: #1512, #1574 Sensitive: no

Description

Required by SAM 3.2 (#1574) and Jetty 9 (#1512).

Would be nice for the following features (add more in comments)

Plan is to start with usage only in apps/ and only those not used in Android and embedded, possibly in 0.9.23 or .24.

In a release or two after that, use in core/router if necessary. Must provide warning to parg at Vuze. Must structure so that it can be removed in the Android build, as it will be quite a while yet before we can require Java 7 for Android. 7 is only supported as of KitKat? (API 19, 4.4, late 2013).

BUT: Also note that as of Marshmallow (API 23, 6.0, late 2015), Android still does not support java.nio.File.

Note this will probably strand XP users.

Note that we've had a warning in the logs about Java 6 since 0.9.17 (late 2014) warning that Java 7 would be required by "mid-2015". In my roadmap slides at I2PCon I proposed 0.9.23 late 2015.

Tasks:

  • Update warning in RouterConsoleRunner?
  • Announcement ahead of time in news, on zzz.i2p, …
  • Add min JDK requirement to news/su3 metadata at release time
  • Update coding style doc on website - what features can we use and where, after discussion on IRC

please add more items below
hopefully I didn't fail to find a previous ticket on this.

Subtickets

Change History (11)

comment:1 Changed 4 years ago by zzz

I'm declaring the upcoming 0.9.23 as the last desktop release to support Java 6.

0.9.24 will require Java 7.

As explained above, this only applies to our desktop releases. Android and embedded apps such as Vuze will get special handling.

comment:2 Changed 4 years ago by str4d

To be clear, Android supports the following Java 7 language features at all API levels (with a compile-time flag):

  • Diamond operator (<>)
  • String switch
  • Multiple-catch (catch (Exc1 | Exc2 e))
  • Underscore in number literals (1_234_567)
  • Binary literals (0b1110111)

What can't be used:

  • The try-with-resources statement - because it requires the non-existing interface java.lang.AutoCloseable (this can be used publicly in 4.4+)
  • The @SafeVarargs annotation — because java.lang.SafeVarargs does not exist

All Android apps I develop that use I2P JARs have the flag enabled. So if we are happy to not use try-with-resources or @SafeVarargs, then I suggest:

  • Nominally require Java 7 for all of I2P, ie. this is the min version we publish, and is both what the I2P desktop application requires, and also what third party developers using our JARs will require. This will limit the necessary special cases.
  • Internally (ie. in I2P dev guidelines), specify the limitations we have on class and language usage, and handle the necessary special-cases. We can either ignore newer non-Android classes entirely, or use SystemVersion.isAndroid() to choose between old and new (e.g. where the new classes offer a significant performance benefit).

comment:3 Changed 4 years ago by zzz

Thanks for the list. I'm not sure I even understand what all of them are, have to read up, esp. on "diamond".

You're right that for each, we should decide yay or nay and put the decisions in our guide.

Right now, the only thing on my radar is the libs, not the language features. For the libs, the trick is to use them only in stuff not in the Android package (e.g. SAM, Jetty, which are the two ticket dependencies on this one), OR have it be easily removable in the Android build (as I'm doing for my WatchService? implementation, see branch i2p.i2p.zzz.dirmon)

It's been a year and a half since we moved to Java 6 minimum, and we actually use surprisingly little of it still. I'm not too worried about a big pent-up demand for it.

One other note: a new report that 7 can be a problem on Macs - see http://zzz.i2p/topics/1969

comment:4 Changed 4 years ago by zzz

Also, I checked in some changes today (didn't bump the rev yet, will be 0.9.22-18) to require Java 7 to download dev builds (either signed or unsigned). Not strictly required until next cycle, but easiest to get it in now. Just in case anybody is trying to run dev builds on java 6…

comment:5 Changed 4 years ago by zzz

near-term proposal (i.e. starting with 0.9.24):


Embedded
core, router, mstreaming, streaming

6 to compile, 6 to run
no 7 libs or language features


Android
above + i2ptunnel (non-UI), addressbook, BOB, net.i2p.router.news

7 to compile, 6 to run
no 7 libs; 7 language features compatible with 6 TBD


Desktop
above + console, i2ptunnel UI, susidns, susimail, i2psnark, jetty, SAM

7 to compile, 7 to run
7 libs ok; 7 language features TBD


comment:6 Changed 4 years ago by zzz

I reviewed the java 7 language features. I do not have any stylistic objections to any of them.

Re: my proposal in comment 5 above, note that for embedded and Android, we may be willing to require limited class removal/replacement to compile/run on 6, similar to what we do now in Android in a couple of places. That's the way I'm doing FileMonitor? now, but perhaps it would be easier to move it to the router console so embedded and android won't see it.

comment:7 Changed 4 years ago by Zlatin Balevsky

Through gratuitous use of reflection it's possible to write code that compiles on 6 and uses libs from 7. It's very tedious but possible.

comment:8 Changed 4 years ago by zzz

@zab indeed, but that's not what we need. I don't think there's any objection to requiring 7 to compile.

The opposite case - compiling on 7 and runs on 6, falling back to something when it can't find the 7 libs, is more helpful, and can indeed be dealt with using reflection. However as you state it's far too tedious for anything but the most trivial use. More cleanly solved by ripping out the code in the build process for Android (and embedded, if necessary)

comment:9 Changed 4 years ago by zzz

Summary bar warning added in 6869e12f631bfb3ef70f7777f15bc6616e794b13 to be 0.9.22-19

comment:10 Changed 4 years ago by zzz

Owner: set to zzz
Status: newaccepted

The only component to require Java 7 in 0.9.24 will be SAM. In i2p.i2p.zzz.sam branch to be propped soon.

comment:11 Changed 4 years ago by zzz

Resolution: fixed
Status: acceptedclosed

propped in 0.9.23-3

Note: See TracTickets for help on using tickets.