bingoohuang/blog

向左还是向右:OpenJDK,烈酒咖啡?龙井茶?

Opened this issue · 12 comments

话说要选个OpenJDK的版本。也就Amazon Corretto 和 Alibaba Dragonwell。没有做具体对标之前 ,心里其实大概有了一个谱,那就是选Amazon Corretto。因为Alibaba在开源上,除了一些工具类的(例如druid)还可信赖之外,其它方面,臭名昭著例如dubbo发布一个初始版本,做一番宣传blabla,然后多年不维护,内部使用与外部开源分离。

对标:

PK Amazon Corretto Alibaba Dragonwell
官方简介 Amazon Corretto 是开放 Java 开发工具包 (OpenJDK) 的免费、多平台、生产就绪型发行版。Corretto 提供长期支持,其中包括性能增强和安全修复。亚马逊在内部的数千种生产服务上运行 Corretto,并且 Corretto 已被证明能够兼容 Java SE 标准。借助 Corretto,您可以在常用操作系统(包括 Linux、Windows 和 macOS)上开发和运行 Java 应用程序。 Alibaba Dragonwell, as a downstream version of OpenJDK, is the in-house OpenJDK implementation at Alibaba optimized for online e-commerce, financial, logistics applications running on 100,000+ servers. Alibaba Dragonwell is the engine that runs these distributed Java applications in extreme scaling.
v8 生产就绪 未标明
v11 生产就绪
平台 Linux x64 Windows x64/x86 macOS x64 Amazon Linux 2 x64/aarch64 (试验中) Linux/x86_64
下载 corretto-8 corretto-11 dragonwell8
文档 corretto 相对全面 文档 少之又少
首页 corretto

参考:

  1. 靠谱的OpenJDK发行版推荐,Corretto & Dragonwell
  2. 独家!阿里开源自用 OpenJDK 版本,Java 社区迎来**力量
  3. Differences Between Oracle JDK and OpenJDK
  4. Wiki:Free and open source implementations
  5. openjdk Docker Official Images

Corretto 由 Caffè Corttto (卡瑞托咖啡)演变而来。卡瑞托咖啡是一种意大利饮料,它由意大利浓缩咖啡与一种类似白兰地意大利酒混合而成,由于加入了 酒精,使得这种咖啡散发出特殊的香味,味道很独特,加烈酒的比例一般是3:1,可以根据自己的喜好加。

image

“Dragonwell”中文译为龙井,象征着**的茶文化,又恰好是杭州特色(阿里巴巴总部所在地);“well”一词通常被描述为水源汇聚在一起供大家享用,我们希望可以集合所有开发者的力量不断完善该项目并最终贡献给所有用户。

image

以下InfoQ采访中话语,佐证阿里内部并不直接使用Dragonwell。

2015 年,统一后的阿里 JVM 团队开始着手基于 OpenJDK 8 进行优化和定制工作,并推出了如今众所周知的定制版 AJDK (Alibaba/AlipayJDK) ,这几乎承载了淘宝、天猫,蚂蚁,菜鸟的所有核心应用,并经受住了多次双十一考验。

那么,如今开源的 Alibaba Dragonwell 与阿里内部使用的 AJDK 是一个东西吗?

通过阿里的业务运行情况来看,AJDK 的功能和性能确实不错,但本次开源的 Alibaba Dragonwell 与 AJDK 还是有差异的。李三红表示,Alibaba Dragonwell 是 AJDK 的开源版本,AJDK 技术的继承者。目前开源的版本并未包含 AJDK 的所有功能,比如多租户,Wisp 协程,ZenGC 等,主要是因为开源一个技术会涉及到比较长时间的准备。

版本更新历史对比

来自corretto-8变更日志的数据:

  1. 2019年5月2日 适用于 Amazon Linux 2 的 Corretto 版本 8.212.04.2
  2. 2019年4月21日 Corretto 版本 8.212.04.2
  3. 2019年4月16日 关键补丁更新:Corretto 版本 8.212.04.1
  4. 2019年1月25日 8.202.08.2:Amazon Corretto 8 RC。
  5. 2019年1月25日 8u202 PSU 版本:适用于 Amazon Linux 2 的 Corretto 版本 8.202.08.1。
  6. 2019年1月23日 8u202 PSU 版本:Corretto 版本 8.202.08.1
  7. 2019年1月16日 新平台版本:版本 1.8.0_192-amazon-corretto-preview2-b12 和 1.8.0_192-amazon-corretto-preview2_1-b12
  8. 2018年12月17日 错误修复版本:版本 1.8.0_192-amazon-corretto-preview2-b12
  9. 2018年11月14日 初始版本:版本 1.8.0_192-amazon-corretto-preview-b12

来自Alibaba Dragonwell8 Release Notes

  1. 2019年3月19日

    Alibaba Dragonwell 8.0-preview openjdk version "1.8.0_202"
    OpenJDK Runtime Environment (Dragonwell 8.0-preview) (build 1.8.0_202-b27)
    OpenJDK 64-Bit Server VM (Dragonwell 8.0-preview) (build 25.202-b27, mixed mode)

当然Corretto啦

Mac上动态切换Java版本:

➜  notify4g git:(master) /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.0_212, x86_64:	"Amazon Corretto 8"	/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
    1.8.0_191, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home

➜  notify4g git:(master) export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_191`
➜  notify4g git:(master) java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
➜  notify4g git:(master) /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home

➜  notify4g git:(master) export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_212`
➜  notify4g git:(master) java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment Corretto-8.212.04.2 (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM Corretto-8.212.04.2 (build 25.212-b04, mixed mode)
➜  notify4g git:(master) /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
Java SE history OpenJDK versions
JDK Beta – 1995
JDK 1.0 – January 1996
JDK 1.1 – February 1997
J2SE 1.2 – December 1998
J2SE 1.3 – May 2000
J2SE 1.4 – February 2002
J2SE 5.0 – September 2004
Java SE 6 – Dec 2006 OpenJDK 6 project – 基于JDK 7, 经修改提供Java6的开源版本
Java SE 7 – July 2011 OpenJDK 7 project – 28 July 2011
Java SE 8 (LTS) – March 2014 OpenJDK 8 project – 18 March 2014
OpenJDK 8u project
Java SE 9 – Sep 2017 OpenJDK 9 project – 21 Sept 2017
Java SE 10 (18.3) – Mar 2018 JDK project release 10 – 20 Mar 2018
Java SE 11 (18.9 LTS) – Sep 2018 JDK project release 11 – 25 Sep 2018
Java SE 12 (19.3) – March 2019 JDK project release 12 – Stabilization phase

infoworld报道

Red Hat to maintain OpenJDK 8 and OpenJDK 11
Red Hat will be providing bug fixes and security patches for the two older releases of the Java Development Kit, taking over from Oracle

一篇SO的文章,Difference between OpenJDK and AdoptOpenJDK,说得很好,摘录一下:

In short:

  • OpenJDK has multiple meanings and can be referred as:

    • free and open source implementation of the Java Platform, Standard Edition (Java SE)
    • open source repository - the Java source code aka OpenJDK project
    • prebuilt OpenJDK binaries provided by Oracle
  • AdoptOpenJDK prebuilt OpenJDK binaries provided by community.

Explanation:

Prebuilt OpenJDK (or distribution) - binaries, built from http://hg.openjdk.java.net/, provided in a zip or installer, offered for various platforms, with a possible support contract.

OpenJDK, the source repository (also called OpenJDK project) - is a Mercurial-based [open source repository)[http://hg.openjdk.java.net). The Java source code. The vast majority of Java features (from the VM and the core libraries to the compiler) are based solely on this source repository. Oracle have an alternate fork of this.

OpenJDK, the distribution (see the list of providers below) - is free as in beer and kind of free as in speech, but, you do not get to call Oracle if you have problems with it. There is no support contract. Furthermore, Oracle will only release updates to any OpenJDK (the distribution) version if that release is the most recent Java release (including LTS). The day oracle releases OpenJDK (the distribution) version 12.0, even if there's a security issue with OpenJDK (the distribution) version 11.0, Oracle shall not release an update for 11.0. Maintained solely by Oracle.

AdoptOpenJDK, the distribution - very similar to Oracle's OpenJDK distribution (in that it is free, and it is a build produced by compiling the sources from the OpenJDK source repository). AdoptOpenJDK as an entity will not be backporting patches, i.e. there won't be an AdoptOpenJDK 'fork/version' that is materially different from upstream (except for some build script patches for things like Win32 support). Meaning, if members of the community (Oracle or others, but not AdoptOpenJDK as an entity) backport security fixes to updates of OpenJDK LTS versions, then AdoptOpenJDK will provide builds for those. Maintained by OpenJDK community.

There's also OracleJDK - another distribution, starting with JDK12 there will be no free version of this. Oracle's JDK distribution offering intended for commercial support. You pay for this, but then you do get to rely on Oracle for support. Unlike Oracle's OpenJDK offering, the OracleJDK offering does come with longer support for LTS versions. As a developer you can get a free license for personal/development use only of this particular JDK, but that's mostly a red herring, as 'just the binary' is basically the same as the OpenJDK binary. I guess it means you can download security-patched versions of LTS JDKs from Oracle's websites as long as you promise not to use them commercially.

Note. It maybe best to call the OpenJDK builds by Oracle, the "Oracle OpenJDK builds".

Donald Smith, Java product manager at Oracle writes:

Ideally, we would simply refer to all Oracle JDK builds as the "Oracle JDK," either under the GPL or the commercial license depending on your situation. However, for historical reasons while the small remaining differences exist, we will refer to them separately as Oracle’s OpenJDK builds, and the Oracle JDK.

OpenJDK Providers and Comparison

---------------------------------------------------------------------------
|     Provider      | Free Builds | Free Binary   | Extended | Commercial |
|                   | from Source | Distributions | Updates* | Support    |  
|-------------------------------------------------------------------------|               
| AdoptOpenJDK      |    Yes      |    Yes        |   Yes    |   No       |
| Azul              |    No       |    Yes        |   Yes    |   Yes      |
| IBM               |    No       |    No         |   Yes    |   Yes      |
| Mercurial         |    Yes      |    Yes        |   No     |   No       |
| Oracle            |    No       |    Yes        |   No**   |   Yes      |
| RedHat            |    Yes      |    Yes        |   Yes    |   Yes      |
| SapMachine        |    Yes      |    Yes        |   Yes    |   Yes      |
| Amazon – Corretto |    Yes      |    Yes        |   Yes    |   No       |
---------------------------------------------------------------------------

* Extended Updates - Public Updates beyond the 6-month release lifecycle
** Oracle provides extended updates (and support) to paying customers, i.e. Oracle JDK only

Additional information

  1. Time to look beyond Oracle's JDK by Stephen Colebourne
  2. Java Is Still Free by Java Champions community (published on September 17, 2018)
  3. Java is Still Free 2.0.3 by Java Champions community (published on March 3, 2019)

https://adoptopenjdk.net/releases.html#x64_linux

image

Java版本选择:

alias java_ls='/usr/libexec/java_home -V 2>&1 | grep -E "\d.\d.\d[,_]" | cut -d , -f 1 | colrm 1 4 | grep -v Home'

function java_use() {
    export JAVA_HOME=$(/usr/libexec/java_home -v $1)
    echo export "JAVA_HOME=$(/usr/libexec/java_home -v $1)" > ~/.mavenrc
    export PATH=$JAVA_HOME/bin:$PATH
    java -version
}

zxiaofan/JDK: Source code for multiple JDK versions(1.6/1.7/1.8/1.9/10/11/12 JDK's src.zip), Only for learning; "rt_debug.jar" can be used for debugging.

JDK那些事儿

Sun JDK、Oracle JDK 和 Open JDK:

  1. Sun JDK 是Sun公司还没被Oracle收购的时候 JDK名字的叫法。

  2. Oracle JDK 顾名思义是Oracle公司旗下的,而Open JDK 是Sun在2006年末把Java开源而形成的项目。

  3. Oracle JDK 和 Open JDK 主要区别在于:

    • OpenJDK采用GPL V2协议,而Oracle JDK则采用JRL协议。
    • 二者虽然都是开放源代码的,但是在使用上的不同在于GPL V2允许在商业上使用,而JRL只允许个人研究使用;
    • OpenJDK源代码不完整:这个很容易想到,在采用GPL协议的OpenJDK中,Oracle JDK的一部分源代码因为产权的问题无法开放给OpenJDK使用,其中最主要的部份就是JMX中的可选元件SNMP部份的代码;
    • OpenJDK只包含最精简的JDK(也就是说没有Oracle JDK Deployment(部署)功能:主要包括:Browser Plugin、Java Web Start、以及Java控制面板)