The question is actually twofold:
Can Java9 projects be analysed with SonarQube?
Can SonarQube itself run on a Java9 JVM?
Same question for Java8
TL;DR: YES!!! It supports analysis, apparently since 3rd July 2017 (But they are desperately trying to hide the fact...)
As of now (2017-10-24, SonarQube version 6.6), SonarQube can analyse Java9 code using SonarJava 4.11 or newer, but running on a Java9 JVM is not officially supported.
SonarQube Java Plugin compatibility
The SonarJava page states it supports Java versions through 10:
Supported versions, frameworks and special analyses
Java language versions through 10
The SonarJava 4.11 release news also states:
The SonarSource Team is pleased to announce the release of SonarJava version 4.11.
This version introduces support for Java 9 projects. But what does that mean?
This means being able to parse the module-info.java source files introduced by the jigsaw project.
Also, same page explicitly lists support for:
Try-With-Resources enhancements
Interface private methods
Diamond Operator Extension
JaCoCo reports for Java9 classes
SonarQube platform compatibility
link
Supported Platforms
The SonarQube Java analyzer is able to analyze any kind of Java source files regardless of the version of Java they comply to. But SonarQube analysis and the SonarQube Server require specific versions of the JVM.
Support:
Oracle JRE 7 ❌
Oracle JRE 8 ✓
Oracle JRE 9 ❌
OpenJDK 7 ❌
OpenJDK 8 ✓
OpenJDK 9 ❌
IBM JRE ❌
GCJ ❌
Oracle JRockit ❌
Links:
SonarQube JIRA queue for search string "java 9"
SonarQube JIRA queue for search string "java9"
SonarQube JIRA ticket "MMF-833: Make SonarJava supporting the analyzis of Java 9 projects"
Related
I have a Spring Boot application and I'm trying to set the JDK to OpenJDK-17. I've downloaded it from Java, then I go to IDE and Project Settings > Project Structure > SDKs, and then I click on the '+' > Download JDK. Then when I set the version to 17, I don't see OpenJDK-17 anywhere...
I get the following options:
Amazon Corretto 17.0.6
Azul Zulu Community 17.0.6
BellSoft Liberica JDK 17.0.5
Eclipse Temurin (AdoptOpenJDK HotSpot) 17.0.5
GraalVM Community Edition 17
IBM Semeru (AdoptOpenJDK OpenJ9) 17.0.5
SAP SapMachine 17.0.5
---------Other Versions---------
Oracle OpenJDK 19.0.2
I don't know for sure the rational of the Intellij for (no longer?) including a link to a "vanilla" OpenJDK 17 download site. However my guess is that it is related to this notice on the https://jdk.java.net/17/ release page:
JDK 17 Releases
JDK 17 has been superseded. Please visit jdk.java.net for the current version.
Older releases, which do not include the most up to date security vulnerability fixes and are no longer recommended for use in production, remain available in the OpenJDK Archive.
Note that the OpenJDK team are no longer publishing new builds for OpenJDK 17. If you want the current Java 17 LTS build, you get it as an Oracle release or you get it from a 3rd-party vendor. These should all include the most recent security patches.
The Intellij team would be doing users a disservice if they provided an easy way for users to download an old and potentially insecure OpenJDK Java 17 build.
OpenJDK is basically a source only project (though they do release reference binaries for the first six months, which usually results in three releases, e.g. 17.0.0 - 17.0.2). After those three months, newer releases are only available through the vendors (e.g. for Java 17.0.5). All those listed are variants of OpenJDK 17 (except IBM Semeru, which is OpenJ9, which itself is a variant of OpenJDK). And bar vendor specific extras, or optional features like garbage collectors, they are basically the same, and have been tested for compliance with the Java specification.
In the Java world, you pick a vendor, and use its binaries instead of the binaries from OpenJDK itself (which generally don't go further then x.0.2, while vendor specific versions continue to receive updates if they are LTS versions). Personally, I usually use Eclipse Temurin builds.
Quoting the okhttp github page:
The OkHttp 3.12.x branch supports Android 2.3+ (API level 9+) and Java 7+
But looking at com.squareup.okhttp3:okhttp:3.12.12 (seems to be the latest 3.12.x release at the time of writing), we find the following:
import java.time.Duration; // OkHttpClient.java line 23
and various uses of Duration which is a java 8 feature. This makes my code break at runtime with a:
java.lang.ClassNotFoundException: java.time.Duration
when running with:
java version "1.7.0_251"
Java(TM) SE Runtime Environment (build 1.7.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 24.251-b08, mixed mode)
which is a hard requirement in my target environment.
Is there in fact a java 7 compatible decently recent version of okhttp?
The way I read the tea leaves (as in not the docs) is that the 3.12.x branch is mostly there to support android where I assume things might be slightly different and packages like java.time are actually available in java 7 under certain conditions.
Assuming it is actually not possible to use okhttp 3.12.x from java 7 (normal, not android), it might be good to update the docs to reflect this to save somebody else the explorative journey I just went through.
< edit - comment added after response by yuri >
I created a gist with a stack trace here. The breaking statement on line 53 is:
client = new OkHttpClient.Builder()
.addInterceptor(interceptor)
.build()
(removing the addInterceptor call does not fix the problem)
Also it should be noted that this is a small, two-class project which I'm building with java 11, then using the mechanics in later versions of gradle (and java) to target java 7 and finally executing the fat jar with the above java 7 version. Quoting the gradle description:
Since version 9, the Java compiler can be configured to produce bytecode for an older Java version while making sure the code does not use any APIs from a more recent version.
So I'm building with:
------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------
Build time: 2020-08-10 22:06:19 UTC
Revision: d119144684a0c301aea027b79857815659e431b9
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.7 (Amazon.com Inc. 11.0.7+10-LTS)
OS: Mac OS X 10.15.5 x86_64
and running with the above mentioned oracle java 7.
The reason I'm building with java 11 is that building with java 7 forces me to downgrade gradle and a number of plugins to ancient versions and just generally becomes a mess. Possible, but would be nice not to.
Answering my own question. After some feedback from the okhttp devs on an issue created for this at:
https://github.com/square/okhttp/issues/6221
it seems that this issue is caused by groovy's use of reflective access / introspection.
I added the CompileStatic annotation:
https://docs.groovy-lang.org/latest/html/gapi/groovy/transform/CompileStatic.html
to the method exhibiting the issue and the issue is now gone.
We are planning to migrate our project from Oracle JDK to OpenJDK. I have some questions regarding the same.
After doing some analysis I found that OpenJDK will have a feature release every 6 months which is only supported until the next feature release.It's essentially a continuous stream of releases targeted to developers. Now my question is will it be a good idea to migrate to OpenJDK. Because if the
above statement is correct then we need to upgrade OpenJDK in our application every 6 months
Ref : Differences between Oracle JDK and OpenJDK
What are the basic changes required to do this migration. When I say basic changes, I mean I need to understand in very high level.One thing I know that is
Oracle JDK and Open JDK are having different jar licences. So do I need to replace all Oracle JDK jars with OpenJDK jars as its mentioned in
Migrating to OpenJDK from Oracle JDK ?
Currently we are using :
JDK 1.8
Tomcat 8
Windows Operating System for development. Services gets deployed in linux OS
Maven Build tool
Appreciate your help.
Thanks
Now my question is will it be a good idea to migrate to OpenJDK
For Java 11 you might want to, though by Java 11 they will be almost identical.
So do I need to replace all Oracle JDK jars with OpenJDK jars
I would install a version of OpenJDK and use the JARs which came with it. I wouldn't mix and match them.
JDK 1.8
I am not sure gain anything by migrating Java 8. Oracle Java 8 is still supported at least until Jan 2019. After that, you might not get any update, but you might not with OpenJDK either.
If your concern is getting support for Java 8, I suggest contacting a company which will give commercial support Java 8 such as Azul for what seemed like a reasonable price. https://www.azul.com/downloads/zulu/zulu-windows/
I have Java 8 installed on my computer, before it was Java 7. But I need to work with version 6.
How can I install Java 6? On Oracle website, it is no longer possible to download the old versions.
How can I downgrade Java if it was not installed before?
Please be aware that Java 6 is no longer receiving public updates. You always should use the most updated Java version.
But you can find some historical Java releases on Oracle Java Archive. The page warns:
WARNING: These older versions of the JRE and JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production.
These are the links to download old versions of Java SE:
Java SE 8 Archive Downloads
Java SE 7 Archive Downloads
Java SE 6 Archive Downloads
Java SE 5 Archive Downloads
Java SE 1.4 Archive Downloads
Java SE 1.3 Archive Downloads
Java SE 1.2 Archive Downloads
Java SE 1.1 Archive Downloads
It's possible. A lot of notable software can be traced to the very first version (for testing or other purposes). You can actually find and download the first version of Firefox, Chrome, Netbeans, WordPress etc. The same with Java. They just make it a little bit more difficult to dig the old versions up, and they intentionally hide it for good reasons.
These older versions of the JRE and JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production.
and
Keeping old and unsupported versions of Java on your system presents a serious security risk.
(and Java is already not really reputable, security-wise)
You cannot "downgrade" a certain version of Java. You install different versions of Java you need, and set your project to be built with that specific version. On a system, there can be several Java versions installed together.
Are Open JDK and JDK7 the same thing?
Open JDK is a free (but not certified) implementation of the JLS (java language specification) where JDK7 is the next version of Sun's JDK which is currently 1.6 (or just Java 6 as the marketing devision of Sun called it).
OpenJDK was initially based only on the JDK 7.0 version of the Java platform.
Since February 15, 2008, there are two separate OpenJDK projects:
The main OpenJDK project, which is based on the JDK 7.0 version of the Java platform
The JDK 6 project, which provides an Open-source version of Java 6.0.
I hope this clears the confusion a bit.
It appears to be a Solaris<-->OpenSolaris situation, viz. there's an open-source project with as much code as possible; the fixes get transferred back to the main software, which the vendor supports and sells. OpenJDK is a project. OpenJDK version 7 and JDK7 appear to be largely but not exactly the same (per here).