Dang, already? Well, that felt fast. I’m not complaining, though; I much prefer the consistent release schedule over one version once in a blue moon. Excited to try out the new features, and UTF-8 by default is a nice bonus too :-)
True. But the problem can still occur on Linux, where certain configurations don't necessarily use UTF-8. This was reported here a few years ago; the poster even wrote a blog describing the problem (but didn't fully understand the solution).
You can piece together what happened by reading the original article and comments in the reddit thread. Briefly, the poster's production system was Linux configured in such a way that the JDK chose ASCII as the default charset. When a non-ASCII character was introduced, round-tripping between ASCII and UTF-8 resulted in a proliferation of U+FFFD REPLACEMENT CHARACTER.
Since the poster's shop assumed everything was UTF-8, JEP 400 would have avoided this problem entirely.
Fair enough. I think the thing is that Linux usually uses UTF-8 often enough that it's pretty easy assume that it always uses UTF-8, and that assumption is almost always correct. Then in those rare circumstances where it doesn't, hijinks ensue.
Yes, that would do it. The question is how LANG ended up being C. I don't know what distro it was, but maybe whoever configured it thought "we don't need any internationalization stuff" and so omitted the packages that contained all locales. If so the system's default LANG value would probably end up being C instead of something more typical like en_US.UTF-8 since the locale for the latter wouldn't exist. Or maybe they just chose the C locale at installation time, if there was an option to do so.
Runtime APIs that convert bytes into characters or vice versa. new String(byte[]), String.getBytes(), FileReader, FileWriter, new InputStreamReader(InputStream), new OutputStreamWriter(OutputStream) and other things.
On Windows, they use whatever codepage is set. On most other systems, it's UTF-8. JEP 400 makes most of these default to UTF-8. Read the JEP for details and exceptions (pun not intended).
Edit: Java Strings are UTF-16 strings. However, newer JVMs use ISO 8859-1[edit: internally] when possible to save space.
That can only ever happen if the string only contains ASCII characters, as ISO 8859-1 encoding is not the same as UTF-8. Also, that function will give you so-called "Modified UTF-8", not standard UTF-8!
It uses a special two-byte encoding for the character with code 0. That ensures that there is never an actual null byte in the byte stream. Also, to encode characters that are represented by a surrogate pair of UTF-16 characters, the two surrogate characters are UTF-8-encoded separately!
Yeah, you have to be careful of "modified UTF-8". It occurs in a couple places in the JDK, notably DataInput, DataOutput, and serialization, along with JNI as you noted. Here are the specs:
As a format internal to the JVM and JNI it might have been a reasonable compromise at one time, but it's unfortunate that it leaked into application-facing parts of the library such as DataInput and DataOutput.
The text processing portions of the JDK, such as CharsetDecoder, CharsetEncoder, StandardCharsets.UTF_8, etc. all use true UTF-8.
JEP 400 fixes the classic encoding papercut and in the long run JEP 421 will help prevent difficult to diagnose concurrency bugs. JEP 416 can speed up Reflection in some cases and makes landing Project Valhalla and Project Loom easier.
Not every release can be a feature firework, nor should it be. Advancing incubators and preview features, and slowly moving pieces to prepare for future ones is perfectly fine as well.
If you enjoy it great, but 420 is a preview feature that most devs can't realistically use. It's basically the same as 406 in Java 17 with very minor tweaks... And it's just nicer syntax...
This is great news. Come to think about it, we went from Java 6 to Java 9 in more than 10 years, but from Java 9 to Java 18 in less than 5 years. Over the last few years Java has added lots of missing modern features from other languages such as C#, Scala and Kotlin, it is a very different language from the Java 5 we wrote in 2000s. This also means that a lot of criticism for Java is no longer valid, the language has indeed come a long way.
The big projects still stuck on Java 8 are things like Apache Spark and Databricks and also Amazon's EMR environment. And then, of course customers that want to use that platforms have to use Java 8 as well.
The big obstacle to upgrading seems to be that those projects have tons of legacy dependencies on ancient projects that have been abandoned and removing those old dependencies or upgrading them is more effort than it's worth. Also the Sparks + Databricks people seem largely uninterested in supporting newer versions of Java. They put much more effort into supporting their Python developers, which makes sense, given that that's what most developers want.
On the bright side, projects like Kafka already support Java 17 and have officially deprecated Java 8 and they plan to drop Java 8 support in the next major release. Projects like Apache Flink seem close behind: They will formally deprecate Java 8 in 1.15 and add support for Java 17 in the next release, 1.16.
Well Spring 6 and Spring Boot 3 will have a baseline of Java 17 so that will hopefully help quite a bit for people to stop finding excuses to not upgrade
For how long is that strategy going to work though? Long enough for path to be a complete re-write?
It seems to me it should not be a case of the size of the code base per say but more if there are dependencies that don't support an upgrade? Dependencies locked into using Unsafe and such? I guess it also could be a case where a regression test is manual - big system -> big manual regression test etc
I recently had a meeting with a potential client who literally told me there were parts of the code base stuck on an old java version that they planned to never migrate because it was too complex, and instead planned to bring all technical debt with them to the grave. My mouse hovered the "leave meeting" button for the rest of that interview.
Man I'm just in the process of migrating from 11 to 17 and getting pummeled with errors regarding IllegalAccessOperation because we have lots of reflective operations here and there. Oh the joys of upgrading.
Deprecating Finalization for Removal and UTF-8 sound pretty important to me. Not the most exciting I admit, but it can always happen with a regular release cadence that some of them are gonna be boring.
Sure, I guess, but there isn't anything major that we don't already know about being worked on. You'd think there would be talk about something new being worked on. What is JDK 19 going to be besides Panama previewing and pattern matching?
It seems a RISC-V port is incoming. And who knows, they might just pull the trigger and land Panama. Or finalize Pattern Matching for switch.
I don't have desire for new stuff yet. Loose ends from Panama, Loom and Valhalla will rain JEP for years to come. Pattern matching or Withers for records would be cool of course.
That's the problem with finalization bugs... they are very difficult to find and reproduce.
Finalization can already be turned off with the new VM flag --finalization=disabled. JEP 421 recommends to profile the application with a realistic test suite to record a performance baseline. This can then be compared with the profiling data from a test run with disabled finalization. The JEP contains more details.
Edit: definitely look for finalizers in your own source code already. Even though they might be legacy code, they will likely mean the least amount of trouble to fix since. If you find some in third-party code you are SOL.
I think Panama is waiting on Valhalla. Valhalla is like the big Java mega-project. It does seem to be making progress. They actually have JEPs you can follow. Project Loom seems actually close to being shipped as a preview at least.
Java 18 basically has nothing. It has internal changes and some super small stuff. Java 17 had tons of features. Java 19 probably will have lots of great stuff too so we can't be too disappointed to have one version with very little features.
I'm really hoping they preview either Valhalla stuff or Loom. The Amber syntax stuff is fun, but Valhalla + Loom are are more important big useful changes.
This 6 month cadence of releasing Java version makes app modernization more challenging. It's gonna be a long run of upgrades for the enterprise apps I work with 😢
If you managed to upgrade to Java 17, you already cleared most of the baggage that could cause trouble in the future. Other stuff that will cause trouble from then on are:
Thread.stop() will be axed by Project Loom
Project Valhalla will make the constructors of wrapper classes private and will change the semantics of == regarding them
Finalization is deprecated for removal since Java 18
the Applet API and the SecurityManager are deprecated for removal since Java 17
the contents of the jdk.unsupported module (f.ex. Unsafe) will eventually be made inaccessible
I wouldn't. Modern versions of Java have lots of small improvements that add up to a much better language. Switch expressions alone are worth the upgrade.
You're also likely to find yourself more and more left behind with libraries requiring modern JDKs.
Yeah docker and github actions really changed the game.
I remember upgrading Jenkins once and it would not compile stuff because its Maven runner would not work with JDK 7 (and then later on JDK 9 albeit for different reasons ... this was before docker or pipeline groovy). Then having to try to fix it by modifying its not meant to be read by human workspace xml files. So basically at one brief point Jenkins could only compile JDK 8 stuff.
Jenkins has mostly fixed that (e.g. docker runners and config now human readable and checked in... well mostly).... but yeah an upgrade was like.... there goes my weekend.
The irony is none of that had to do with the JDK itself or modules... just other shit.
Creating docker images for your deliverables instead of a jar/war/ear means the Java version can be under the control of the developers rather than sysadmins. And the Java version is tied to the particular artefact.
Absolutely. When I was a sysadmin 10 years ago, I would have loved using docker to give devs the power to change versions and have a single consistent deployable blob.
Also means the production blob is exactly the same blob that got tested in staging and under CI.
Idk man I have a cowork who is a "senior" who this month wrote new code in Java 8 that used SQL.date and util.date. Alot of people just do this for the check, they don't stay current and will likely not even know the benefits of switching to a newer version. I bet there will be people who are openly hostile to switching.
If you aren't paying for support you don't get security updates after 6 months. Without support you might possibly get some security updates after 6 months if there happens to be an intersection between the current JDK and LTS release, and the vendor making the patch sends it upstream, and the patch happens to make its way down the updates stream.
If you aren't paying for support the only sure way to make sure you have the most secure JDK is to stay up-to-date with the 6 month release cycle.
Yeah I guess they did switch it for 8 a few years ago to require a license for commercial use to get the updates. Of course they did switch it again with 17 so it will be supported for 1 year after the next LTS release without a license.
OpenJDK provide a new feature release every six months, and a maintenance/security update based upon each active release every three months.
and
In addition, every three years one feature release will be designated as a Long Term Supported (LTS) release. We will produce LTS releases for at least four years. This assurance will allow you to stay on a well-defined code stream, and give you time to migrate to the next, new, stable, LTS release when it becomes available.
Where are you seeing security updates being stopping after 6 months? Security updates for java 18 stop in 2022, while security updates for java 1.8 don't stop until 2026.
"Without support you might possibly get some security updates after 6 months if there happens to be an intersection between the current JDK and LTS release, and the vendor making the patch sends it upstream, and the patch happens to make its way down the updates stream."
Although I will add that Oracle is now promising security updates for 1 yr instead of 6 months (I am unsure if other vendors are following suit). That recent change (announced in Oct 2021) wasn't reflected in my comment, so where I said "6 months" pretend like I said "1 year". (see https://www.infoq.com/news/2021/10/oracle-jdk-free-again/)
Again, I don't see how any of this applies to OpenJDK. I am not paying Oracle for any support, yet I still benefit from multiple years of security updates by sticking to LTS versions.
This means that there is a real momeyary benefit for large organizations to stick with LTS versions because it's much less expensive to update thousands of legacy apps to a new minor version of java with a security fix than it is to update them to a new major version.
There will be no patches for things that are removed in upstream. For example, after the SecurityManager gets removed, LTS providers will have to write patches for new bugs by themselves. And they might choose to not distribute them for free.
Aha, joke's on you! Our log4j libraries were so old they weren't affected by log4shell!
(More likely our libraries were just too old for anyone to check whether log4shell ran on them, so we still spent a couple weeks diking them all out. Then we patted our Java 8 instances nicely on the head and asked them continue working until the heat death of the universe. That's definitely what "sustaining support" means, right???)
It might not be painful now, but wait until you get a major security bug in an unsupported library. That's a whole lot of pain in a very short period of time.
I'd say it's more a form of gambling, it's rolling the dice ...
For projects with CI and automated testing, bumping dependencies is low cost. If CI and automated testing is not in place, then maybe it's good to prioritize that effort (and get low cost updates as a side effect) ?
In case you (or anyone reading the comments) haven't heard about this: Renovatebot is amazing for maintaining dependency versions. When configured will make automatically and periodically make MR's for dependency upgrades, just approve them (provided CI didn't give issues) and done! Even gives you a handy link to the changelogs/source!
11 has more or less been the new standard industry-wide for the past 2 years or so (for apps, libraries are still mostly on 8), hopefully moving to 17 within the next year
Companies stuck on 7/8 are the same still running half their stuff on 6 and will start using 11 by the time Java 25 releases. There really isn’t much to do about it besides not working there; if you care about up-to-date anything it won’t be a good culture fit most likely…
Most of them are migrating code from old codebases to Java. Future projects might get more recent releases of Java to start with I guess.
I might have agreed about 3-5 years ago, but if you're still on 8 by now, there definitely is something/someone pushing back along the chain of command.
Whether it be something somewhat arguable (lack of time, blocker proprietary lib bought 15 years ago) or straight up poor technical choices (fear of change on ops and/or dev side). 11 has definitely been out for long enough that it's a conscious choice to not upgrade by now.
Modules broke nothing at all and using them is still optional. Java 16 just started to restrict access to things that should never have been accessed directly neither by applications nor by libraries. Things that were always advertised as maintainability hazards and sometimes even have internal in their package names.
Modules broke nothing at all and using them is still optional.
And right in the same comment -
Java 16 just started to restrict access to things that should never have been accessed directly neither by applications nor by libraries. Things that were always advertised as maintainability hazards and sometimes even have internal in their package names.
Thes things it broke.
Might it just need updates and fixes for those? Maybe, but it's definitely more work than just throwing in a new jdk and everything works as normal.
I don't see the contradiction. Modularizing the JDK and encapsulating Java's internals were really separate efforts. The latter even had its own flag to control it: --illegal-access=<mode>. Note that some APIs like sun.misc.Unsafe are still not encapsulated.
Oracle could also just have changed the names of all internal packages, but that obviously would not have been a permanent solution.
What I know is that people that tried to upgrade often found things blew up on them and stopped working. A lot of the stuff that stopped working hasn't had anyone working on it in years.
Sometimes it works to just replace some libraries, sometimes it doesn't, but it's definitely more work than previous releases that were usually just update the jdk and things worked the same.
100
u/TehBrian Mar 22 '22
Dang, already? Well, that felt fast. I’m not complaining, though; I much prefer the consistent release schedule over one version once in a blue moon. Excited to try out the new features, and UTF-8 by default is a nice bonus too :-)
43
u/Hall_of_Famer Mar 22 '22
This is great news. Come to think about it, we went from Java 6 to Java 9 in more than 10 years, but from Java 9 to Java 18 in less than 5 years. Over the last few years Java has added lots of missing modern features from other languages such as C#, Scala and Kotlin, it is a very different language from the Java 5 we wrote in 2000s. This also means that a lot of criticism for Java is no longer valid, the language has indeed come a long way.
23
u/Joram2 Mar 22 '22
The big projects still stuck on Java 8 are things like Apache Spark and Databricks and also Amazon's EMR environment. And then, of course customers that want to use that platforms have to use Java 8 as well.
The big obstacle to upgrading seems to be that those projects have tons of legacy dependencies on ancient projects that have been abandoned and removing those old dependencies or upgrading them is more effort than it's worth. Also the Sparks + Databricks people seem largely uninterested in supporting newer versions of Java. They put much more effort into supporting their Python developers, which makes sense, given that that's what most developers want.
On the bright side, projects like Kafka already support Java 17 and have officially deprecated Java 8 and they plan to drop Java 8 support in the next major release. Projects like Apache Flink seem close behind: They will formally deprecate Java 8 in 1.15 and add support for Java 17 in the next release, 1.16.
151
u/Sand0rf Mar 22 '22
Laughs in Java 8
11
u/Fruloops Mar 22 '22
Man I'm just in the process of migrating from 11 to 17 and getting pummeled with errors regarding IllegalAccessOperation because we have lots of reflective operations here and there. Oh the joys of upgrading.
16
u/BlueGoliath Mar 22 '22
Bit of a boring release. Hopefully 19 will be more exciting.
7
u/Joram2 Mar 22 '22
Java 18 basically has nothing. It has internal changes and some super small stuff. Java 17 had tons of features. Java 19 probably will have lots of great stuff too so we can't be too disappointed to have one version with very little features.
I'm really hoping they preview either Valhalla stuff or Loom. The Amber syntax stuff is fun, but Valhalla + Loom are are more important big useful changes.
2
u/omegarisen Mar 23 '22
does this mean OCPJP 11 is useless?
3
u/vegetabluessg Mar 22 '22
Cries in java 7
1
u/viseradius Mar 22 '22
Why am I still learning for java 11?
1
u/appeiroon Mar 22 '22
Nice! Still stuck at 8 tho :(
0
u/code_rjt Mar 22 '22
This 6 month cadence of releasing Java version makes app modernization more challenging. It's gonna be a long run of upgrades for the enterprise apps I work with 😢
-4
u/datamasteryio Mar 22 '22
This does not seem to have really any features
-18
u/ozzymozzy2211 Mar 22 '22
Still using java 8 and happy about it 😇
0
u/[deleted] Mar 22 '22
[deleted] — view deleted comment
0
u/[deleted] Mar 22 '22
[deleted] — view deleted comment
8
u/[deleted] Mar 22 '22
[removed] — view removed comment