4 ms·
Can it be used as a drop-in replacement for JDK 8 or there could be compatibility problems with popular libraries? As I understood, modules are optional and won
by vbezhenar 9y ago
Can it be used as a drop-in replacement for JDK 8 or there could be compatibility problems with popular libraries? As I understood, modules are optional and won't affect code which isn't modules-ready yet?
- dionian 9y agogenerally with every major release you can compile and target code to earlier JVMs with minimal, if any changes. I've heard that the module system is not backwards incompatible, and I would be shocked if it was incompatible with java 8 code out of the box
- kuschku 9y agoThe problem is that some Java 8 code relies on implementation-specific code in the JVM – for example, JetBrains’ IDEs do. As a result, this doesn’t work with Java 9 the same anymore, as basically all that stuff has been moved around.
- dionian 9y agoas usual they have been working on support in the EAPs, I'm guessing 2017.3 works relatively well with jdk9 by now, but i havent tried yet!
- 0x0 9y agoIt broke android studio's jdk selector and it broke android gradle for me. Also eclipse needed a hack in eclipse.ini to even start. Looks like the ecosystem isn't ready yet.
- stevehiehn 9y agoI just got finished dropping it into a decent size Java8 SpringBoot project. The only thing it broke was something to do with JPA. I had to add some dependency for java.xml.bind and now everything works so thats cool.
- elehack 9y agoThere are a few weird incompatibilities around things that have been moved to modules that are disabled by default. This just bit me with the javax.annotation package (moved to a JAX-WS module and turned off by default; this can jack with containers that work with the PreDestroy/PostDestruct annotations but don't pull in the JSR250 dependency from Maven).
- shock 9y agoIt will be hit and miss for a while until the ecosystem stabilizes. A project using Groovy/Griffon didn't build because of issues related to reflection and I had to disable a lot of the reflection "fences" introduced in JDK 9.
- SanderMak 9y agoYou're right in that JDK 9 highly values backward compatibility with JDK 8. However, there are still some caveats because of modularization of the JDK, that can affect your code (or your libraries) even when running on the classpath without modules: - some Java EE technologies that are tradionally part of Java SE as well, won't resolve by default when compiling/running on the classpath (JAXB will be the most noticeable) - JDK 9 strongly encapsulation internal implementation classes (think of types in com.sun.* and sun.* packages). When running on the classpath, there's a lenient form of strong encapsulation: you will get a warning on the console when reflectively using these types. In time, this lenient mode will be switched to a more strict enforcement. Ergo: time to wean code off the dependencies on internal implementation classes The first restriction you'll probably run into (if you for example have a Spring application). The second restriction is more an issue for library maintainers (though you should start complaining to said maintainers if your application starts printing warnings) All in all, it's not a 100% drop-in replacement, but it's close enough for most scenarios. The trick is to make sure your application will keep running in the future as well, when a more strict strong encapsulation regime will be enforced for classpath-applications as well. (full disclosure: I'm author of Java 9 Modularity, O'Reilly, which covers many migrations scenarios as well. See https://javamodularity.com https://javamodularity.com)