Is the OpenJDK JVM the same as the Oracle Java SE JVM? - jvm

I understand that the Oracle Java SE contains closed source extensions and tools that are not part of the OpenJDK however is the Oracle Java SE JVM identical to the OpenJDK JVM or does Oracle make changes to the OpenJDK JVM before releasing it as a Java SE JVM?
Update 1:
I found some info from the JDK7 updates projects: http://openjdk.java.net/projects/jdk7u/qanda.html
Will the 7 Update Project receive security fixes from Oracle?
Yes.
As with OpenJDK 6, security fixes are first kept confidential and applied to a private forest before being pushed to the public forest as part of the general synchronized publication of the fix to effected JDK release trains. In addition, they will not go through the public code review and putback approval process, and their corresponding issues in the Project's issue tracker will not be publicly visible.

OpenJDK is the reference implementation of Java as of version 7.
OpenJDK 7 is the starting point for the version that Oracle distributes as Oracle JDK. Other vendors (e.g. RedHat for IcedTea) may also use OpenJDK as their starting point.
In terms of the differences between OpenJDK and a vendor VM, there may be patches which a vendor wants to apply but which the overall OpenJDK community has not accepted into mainline.
Vendor VMs must, of course, be able to prove that they are in conformance with the TCK if they want to use the Java trademarks to describe their product.
Oracle JDK is also not open-source. This is possible because of Java's dual licensing arrangements, and the fact that Oracle own Java overall.
Do you have more specific questions - as posed, your question is a bit vague. What specific aspects are you interested in?

Related

Get match result by name is not possible when using Java 10

Heading says it all:
Java version information, tested on opensuse:
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
Stacktrace:
java.lang.UnsupportedOperationException: Retrieving groups by name is not supported on this platform.
at kotlin.internal.jdk8.JDK8PlatformImplementations.getMatchResultNamedGroup(JDK8PlatformImplementations.kt:28)
at kotlin.text.MatcherMatchResult$groups$1.get(Regex.kt:260)
at kotlin.text.jdk8.RegexExtensionsJDK8Kt.get(RegexExtensions.kt:33)
Question: Will this be fixed?
I am pretty sure that I can get the first regex, but that might not be possible in many other cases.
Thanks for your help (sorry for formatting, posting from mobile website)
According to the issue KT-20865, this problem is fixed in Kotlin 1.3.20
It is reproduced in Android (Java 8). Use
REGULAR_EXPRESSION.toRegex().find(sample)?.groupValues?.getOrNull(1)
instead, where needed groups start from 1 (see also https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-match-result/group-values.html).

OpenJDK vs Java HotspotVM

Are OpenJDK VM and Oracle Hotspot VM still two different JVMs?
I can't seem to find any somewhat official documentation on anything about OpenJDK VM. Even in OpenJDK homepage there is an HotSpot Group which develops HotSpot VM.
The HotSpot group is comprised of developers involved in the design, implementation, and maintanence of the HotSpot virtual machine
However if I check java -version on my Windows machine it prints out
Java HotSpot(TM) 64-Bit Server VM
But on my Ubuntu VPS
OpenJDK 64-Bit Server VM
If those are two different VMs what are the main differences between them? Do they have different runtime flag sets?
tl;dr
The accepted Answer by apangin is now outdated.
For recent versions such as Java 11, the Oracle JDK product is virtually identical to the OpenJDK project. OpenJDK now includes Oracle's previous offerings: Java Flight Recorder, Java Mission Control, Application Class-Data Sharing, and ZGC.
To quote the Oracle.com blog:
From Java 11 forward, therefore, Oracle JDK builds and OpenJDK builds will be essentially identical.
Oracle JDK & OpenJDK converging
Oracle has made dramatic changes in the last couple years.
Oracle declared their intention to converge their branded Oracle JDK with OpenJDK to feature-parity. Both are based on the OpenJDK code base.
Towards that end, the formerly commercial tools sold by Oracle, Flight Recorder and Mission Control are now open-sourced and donated to the OpenJDK project. See this and this on the OpenJDK site.
Oracle and other members of the OpenJDK consortium have contributed yet more source code to make the OpenJDK code base entirely open-source and unencumbered by licenses other than the GNU GPL+linking exception.
Oracle has changed their licensing terms. The Oracle JDK branded product is no longer free-of-cost for use in production. Alternatively, you can get a free-of-cost distribution of OpenJDK from any of over half a dozen vendors, including one from Oracle. For all the details, see this vital white paper written by pillars of the Java community, Java Is Still Free.
I drew this flowchart to guide you in selecting a JDK source.
Oracle reserves the right to patch their own branded product for an urgent fix or security vulnerability. But the company has stated their intention to also contribute and coordinate with the other OpenJDK members. Oracle continues to own the Java trademarks and to lead the future of the Java platform. For the existing Long-Term Support (LTS) versions 8 and 11, Oracle has ceded stewardship to RedHat (IBM).
HotSpot versus OpenJ9
The Question here asks:
Are OpenJDK VM and Oracle Hotspot VM still two different JVMs?
As discussed above, the two products are converging at feature parity. Regarding HotSpot technology, read on.
HotSpot is one component within both Oracle JDK and OpenJDK, as discussed above. Today’s HotSpot also combines parts from JRockit. Oracle merged the best of both Java engines, having acquired them from Sun Microsystems and BEA Systems.
The Adoptium project (formerly known as AdoptOpenJDK) from the Eclipse Foundation also provides a build of OpenJDK using Eclipse OpenJ9 (based on J9, donated by IBM) as an alternative to HotSpot. When downloading from Adoptium web site, you choose either HotSpot or OpenJ9 from a menu.
Currently, tests seem to show OpenJ9 as dramatically faster to launch while using much less memory, but HotSpot may run faster with sustained usage. But this is still early days for OpenJ9, so investigate for yourself the latest developments.
Oracle HotSpot JVM is based on OpenJDK HotSpot project. So, they are mostly the same VM, except that Oracle JVM has a few additional commercial features, mainly, Java Flight Recorder, Application Class Data Sharing and Cooperative Memory Management.
Runtime flags are almost the same for both VMs; see the complete list using
-XX:+UnlockDiagnosticVMOptions -XX:+UnlockCommercialFeatures -XX:+PrintFlagsFinal
As of JDK 8u131, the only difference is in the following flags (absent in OpenJDK VM):
bool EnableResourceManagementTLABCache = true {product}
bool EnableSharedLookupCache = true {product}
bool FlightRecorder = false {commercial}
ccstr FlightRecorderOptions = {product}
bool LogCommercialFeatures = false {product}
ccstr MemoryRestriction = none {commercial}
bool ResourceManagement = false {commercial}
intx ResourceManagementSampleInterval = -1 {commercial}
ccstr StartFlightRecording = {commercial}
bool TraceSharedLookupCache = false {product}
bool UnlockCommercialFeatures := true {commercial}
bool UseAppCDS = false {commercial}

Where to download Hotspot JVM? Different from Oracle's JVM?

I read a few posts about JVM at Stack Overflow and would like to download a binary copy of the Hotspot JVM, yet I am not able to find it on http://www.java.net.
Beside that, what is the difference between Hotspot JVM and JVMs found at Oracle
Is Oracle JVM good for a production website?
Overview:
This SO question may clear up your questions regarding "What is JVM, Hotspot and OpenJDK".
Basically:
JVM means Java Virtual Machine. The JVM is the underlying runtime that executes java bytecode. There are multiple different implementations out there, all implementing the Java Virtual Machine Specification
HotSpot is the most used implementation of the JVM concept. It is used in both, Oracle JDK and OpenJDK. Oracle's JDK can be downloaded on oracle's website, currently http://www.oracle.com/technetwork/java/javase/downloads/index.html. This is "the typical JVM you will find on a normal user's windows machine".
OpenJDK is the open source project maintaining and impelmenting the HotSpot JVM, but also many other projects beside the JVM such as Graal or VisualVM. On Ubuntu for example you can install this OpenJDK (current version 8) by running sudo apt-get install openjdk8.
Conclusion:
While this explaination is not really perfect, it may be good enough to understand that there is no big difference between Oracle JDK and OpenJDK. If you are interested in a little more info on this, have a look at the SO question Differences between Oracle JDK and Open JDK
JDK / JVM sourcecode:
If you are interested in the source code, OpenJDK is the way to go. Here you can find the current OpenJDK 8 (which includes the HotSpot JVM). Its source code can be found here. It also states how to download the source code:
The jdk8u-dev forest for ongoing development can be cloned using this command: hg clone http://hg.openjdk.java.net/jdk8u/jdk8u-dev;cd jdk8u-dev;sh get_source.sh .
The corresponding master forest jdk8u can be cloned using this command: hg clone http://hg.openjdk.java.net/jdk8u/jdk8u;cd jdk8u;sh get_source.sh .
In addition, the source code for the last release, 8u66, is available by cloning the 8u master forest : http://hg.openjdk.java.net/jdk8u/jdk8u and using the 'jdk8u66-b17' mercurial tag.

Using Java 8 runtimes compiled against Java 7 [duplicate]

Would I encounter any problems running Java programs and associated libraries compiled in Java version 1.6 and 1.7 (I'm compiling using 1.7 whereas some libraries are compiled using 1.6) and running the entire program in a 1.7 JRE?
As answered already you are mostly safe and most products and 3rd party libraries will simply work. However there do exist very rare cases where binary incompatibilities (ones where the class file compiled using older JDK will fail to run in the newer JVM) were introduced between JDK versions.
Official list of Oracle Java incompatibilities between versions:
in Java SE 9 since Java SE 8
in Java SE 8 since Java SE 7
in Java SE 7 since Java SE 6
in Java SE 6 since Java SE 5.0
in Java SE 5.0 since Java SE 1.4.2
Compatibility tool
Packaged with JDK 9, there is a tool called jdeprscan which will verify the compatibility, list no longer used APIs within your code and suggest alternatives(!). You can specify the target JDK version (works for JDK 9, 8, 7 and 6) and it will list incompatibilities specific to your target version.
Additional comment in case of libraries:
A reasonable rule of thumb is to use latest stable release version of library for the JRE version your software targets. Obviously you will find many exceptions from this rule, but in general stability of publicly available libraries usually increases with time.
Naturally API compatibility and versioning have to be considered when changing versions of dependencies.
Again most popular dependencies will have web pages where such information should be available.
If however you are using something a bit more obscure, you can discern which JRE were the classes within your dependency compiled for.
Here is a great answer on how to find out class version. You might need to unzip the JAR file first.
You would not encounter any problems - that's the magic of Java -it's backwards compatible.You can run almost all code from Java 1 on Java 8. There's no reason why Java 6 code won't run on a Java 8 Runtime.
What is interesting, is that for applications written in, let's say, Java 1.4, you even have speed increases when running them on later runtimes. This is because Java is constantly evolving, not just the language known as "Java", but also the JVM (Java virtual machine). I still have source code from more than 10 years ago that still work, as expected in the latest JVM.
If you want to target, let's say, a Java 5 VM, then you can do that with the Java 8 SDK tools. You can ultimately specify which target VM you wish to support, as long as you bear in mind that a version 5 VM might not support all the features a version 8 VM will.
I've just tested code I wrote in Java 5 against the new Java 8 runtime and everything works as expected, so, even though we have a more powerful language and runtime now, we can continue to use our investments of the past. Just that alone makes Java a great development choice for companies.

JBoss 7 on FreeBSD

I heard that JBoss 7 is not certified for FreeBSD - is that correct?
Where can I find a list of supported platforms? (I spent some time googling, but was not successful)
Strictly speaking there is no certified OS for JBoss 7 as only JBoss EAP 6 is supported by Red Hat.
The supported configuration for JBoss EAP 6 (the supported version of community JBoss 7) can be found here: https://access.redhat.com/knowledge/articles/111663
As JBoss is pure java application, a compliant JDK is enough to have a supported system. So if you have the Oracle or IBM JDK running on FreeBSD is will be supported by Red Hat. But they haven't test them with JBoss.
Any way if you want Red Hat support for the EAP you better check with there representative to discus the extends of the support (if the FreeBSD JDK have some compliance bug, they will probably send you back to the JDK supplier. If you chose RHEL with OpenJDK you will have one supplier to blame for any software stack issue, no redirect to another suplier.)
For community JBoss as for other platform, you will be responsible to make it work with your stack. An good first test can be performed by running the standard compliance tests included in the JBoss sources, if it runs on your target platform and JDK it is a good sign that JBoss is working on it.
Certified Support as per Redhat only goes up to 6:
https://access.redhat.com/knowledge/articles/111663
However if you look back at the release docs they have not changed. OS's are the same.