为什么要做这个测试

在对ARM服务器的测试中,需要对JRE on ARM进行兼容性测试。进行本调研。

在Java 1.6版本之前,Java还是SUN Microsystems 的产品,SUN坚持开源免费和社区开放,所以JAVA社区一般都使用SUN发布的JDK版本,除了IBM等公司为了性能等原因有自有版本。但SUN被Oracle收购以后,Oracle对其进行了商业化改造,在社区主导权和JSR制定方面都试图占据主导位置,且自2019年1月开始,限制JavaSE8以上版本只能用于通用计算场景,且更新不可用于商业用途。

因此在Oracle收购SUN之后,在原有多个商业发行版和OpenJDK的基础上,又出现了多个发行版,这些发行版对JSR标准实现的完善程度是需要考量的。

 

其次,在当前国际局势变化情况下,需要提前验证从x86架构向ARM架构迁移的技术可行性,对JRE,MySQL,大数据套件等进行验证。其中包括对基于ARM架构的JRE上是否可以正常运行Java应用进行评测,因此需要对ARM版本的JDK对JSR实现的兼容性进行测试。

 

现在可供替代的发行版包括

 

  • OpenJDK  

openjdk.java.net

IBM Support

 

  • AdoptOpenJDK  TCK tested

 

  • Azul  azul.com。

Zulu Embedded™ is a series of certified builds of OpenJDK that are fully compliant with the Java SE standard. Each build is certified using Azul’s rigorous quality assurance processes and passes the full OpenJDK TCK Java compliance suite. The unsupported Zulu Embedded builds for Arm processors listed on this page are 100% open source and free to download and use without restrictions.  

 

  • BellSoft

for the Raspberry Pi

 

 

ARM架构简介

CISC(复杂指令集计算机)和RISC(精简指令集计算机)是当前CPU的两种架构。它们的区别在于不同的CPU设计理念和方法。早期的CPU全部是CISC架构,它的设计目的是 CISC要用最少的机器语言指令来完成所需的计算任务。

x86架构采用CISC,而ARM采用RISC。

Intel以增加处理器本身复杂度作为代价,去换取更高的性能,但集成的指令集数量越来越多,给硬件带来的负荷也就越来越大,无形中增加了功耗和设计难度。

 

基于CISC的x86架构处理器不断加入指令集,使得处理器日益庞大,但每个指令集用到的频率也越差越大,许多指令到后来已经相当少用,甚至是可以被新的指令所取代。

而ARM架构则大幅简化架构,仅保留所需要的指令,可以让整个处理器更为简化,体积小、效能高。具有低成本、高性能和低耗电的特性。

另外,由于ARM授权的弹性以及核心架构的单纯,ARM的架构可以高密度整合,可以与其它专职核心,像GPU、多媒体译码核心、基频调制解调器、I/O控制等架构整合,透过SoC(System On a Chip,系统单芯片)的方式,通过一颗ARM架构应用处理器完成复杂x86架构处理器的功能,并且通过各种不同的核心分工各司其职。

ARM架构的另一个优点是自由性,只要向ARM买下核心授权,就可以与其它IP公司的方案以及这家授权客户本身的优势技术整合,在知识产权方面更加灵活。

 

但是,

x86系统在兼容性方面至今仍具有无可比拟的优势。ARM系统绝大部分都采用Linux操作系统,且都要单独构建系统,导致其应用软件存在兼容性问题。

 

 

Cross Building for ARM Hard Float

在Ubuntu 12.04和Debian里,除了arm, armel,还出现了一个名为armhf的版本。这个东西是什么?

本文引用地址:http://www.eepw.com.cn/article/201611/317196.htm

众所周知,armel是目前主要的ARM ABI。armhf则是armel的一个变种,主要区别在浮点计算上。

在armel中,关于浮点数计算的约定有三种。

以gcc为例,对应的-mfloat-abi参数值有三个:

soft

soft是指所有浮点运算全部在软件层实现,效率当然不高,适合于早期没有浮点计算单元的ARM处理器;

softfp

softfp是目前armel的默认设置,它将浮点计算交给FPU处理,但函数参数的传递--使用通用的整型寄存器而不是FPU寄存器

hard

hard则使用FPU浮点寄存器将函数参数传递给FPU处理。

需要注意的是,在兼容性上,soft与后两者是兼容的,但softfp和hard两种模式不兼容。

默认情况下,armel使用softfp,因此将hard模式的armel单独作为一个abi,称之为armhf。

 

 

 

 

 

 

JDK Offerings for the Enterprise 对比(4为满分)

 

JDK Offerings for the Enterprise

Azul Zulu Enterprise

Azul Zulu Community

Oracle

Java SE

Amazon

Corretto 

Red Hat

OpenJDK

Adopt-

OpenJDK

PRODUCT AND FEATURES

Based on OpenJDK

4

4

4

4

4

4

100% Open Source, freely available, no field of use restrictions

4

4

0

4

4

4

TCK Tested (guaranteed Java SE compliance)

4

4

4

4

4

0

Patent Grant (inherited patent rights to use the JDK)

4

4

4

4

4

0

Free Quarterly Updates (single build combining security & enhancements)

4

4

0

4

4

4

Performance Parity with Oracle Java SE

4

4

4

4

4

4

Multi-platform (Windows, Linux, macOS, Solaris)

4

4

4

3

2

4

Native Alpine Linux (musl libc)

4

4

0

0

0

0

Multiple Installers & Packages (tar, deb, MSI, DMG, JDK/JREs)

4

4

2

2

2

1

Repos and Updates via yum & apt-get

4

4

0

0

4

0

Java Flight Recorder and Mission Control (for Java 8)

4

4

4

0

0

0

OpenJFX (JavaFX)

4

4

4

4

0

0

LTS (Java 8, 11, …) and Feature Releases (Java 12, 13, 14, …)

4

4

4

2

2

4

Java 7 support

4

4

4

0

4

0

32-bit support

4

4

4

0

4

1

Java Web Start and Applets

0

0

4

0

2

0

 

 

 

 

 

 

JRE兼容性

JRE的兼容性分为三个方面,源码级、二进制和行为,我们考虑在JRE运行环境层面兼容。

  1. Source: Source compatibility concerns translating Java source code into class files.

  2. Binary: Binary compatibility is defined in The Java Language Specification as preserving the ability to link without error.

  3. Behavioral: Behavioral compatibility includes the semantics of the code that is executed at runtime.

 

 

 

 

 

OpenJDK使用TCK工具进行JavaSE的兼容性测试。

 

TCK

Technology Compatibility Kit。A Technology Compatibility Kit (TCK) is a suite of tests that at least nominally checks a particular alleged implementation of a Java Specification Request (JSR) for compliance. It is one of the three required pieces for a ratified JSR in the Java Community Process, which are:

* the JSR specification

* the JSR reference implementation

* the Technology Compatibility Kit (TCK)

 

 

JCK

TCK for the Java platform

The Java Compatibility Kit (a.k.a., the JCK or TCK for Java SE) is available at no charge to developers who are planning to deploy a compatible Java implementation based on code derived from OpenJDK, or are participating in OpenJDK research, bug fixes, code enhancement and/or ports to other hardware/software architectures.

JCK需要申请Oracle官方许可。

 

JT Harness

The JT harness is based on Oracle's JavaTest harness. The JT harness is a general purpose, fully-featured, flexible, and configurable test harness very well suited for most types of unit testing. Originally developed as a test harness to run TCK test suites, it has since evolved into a general purpose test platform.

JTreg

https://hg.openjdk.java.net/code-tools/jtreg

jtreg is the primary test harness that is used for running unit and regression tests for JDK. It was started back in 1997, and currently supports over 10,000 tests that have been written for JDK in the years since then.

 

The early tests for the Java platform were written to test the HotJava browser, and consisted of a series of web pages that had to be manually visited and the instructions followed. That led to the development of conformance tests and the JavaTest test harness, which together formed the Java Compatibility Kit, or JCK. But after the initial introduction of JCK, it became clear we needed a different sort of test harness for running regression tests. JCK tests are defined in a declarative style: "this is a runtime test", "this is an RMI compiler test", "this is a negative compiler test", and the test harness knows how to run the different types of test. But for regression tests, we needed a more imperative style of test: "compile this, then compile that, then run this class file". This led to the jtreg Tag Specification. In addition, the JavaTest test harness began its evolution from "the test harness for JCK" into a framework for creating test harnesses, for test suites such as JCK, and now, as jtharness, for the JDK regression test suite

 

jtreg supports various different types of tests:

* API tests: In general, these have a main program and which pass if the main program returns normally, or fail if the program throws an exception. In addition, support has also been added recently for including TestNG tests within a jtreg test suite.

* Compiler tests: These consist of one or more source files which either should compile (a positive test) or should not compile (a negative test).

* Applet tests: These consist of an HTML file containing an applet tag, and source files for the corresponding applet class. Some amount of manual interaction is required to determine if the test passed or failed.

* Shell tests: These consist of a shell script and any additional files as needed. They can be used to create tests that do not easily fall into any of the preceding categories. Such a test passes if and only if the script exits with a 0 return code.

 

可以视为在JUnit和Ant出现前专门为了JCK测试实现的测试套件。

 

jtreg依赖JT Harness, TestNG, JUnit, AsmTools. Ant, and JCov.

 

使用build/build-all可以自动下载依赖并编译。

 

 

 

 

 

参考资料


  1. https://www.oracle.com/technetwork/java/javase/compatibility-137541.html

  2. https://en.wikipedia.org/wiki/Technology_Compatibility_Kit

  3. https://openjdk.java.net/groups/conformance/JckAccess/

  4. https://jcp.org/en/resources/tdk

  5. http://www.oracle.com/us/corporate/accessibility/templates/t2-4506.html

  6. http://www.oracle.com/us/corporate/accessibility/templates/t2-5360.html

  7. http://hg.openjdk.java.net/code-tools/jtharness

  8. https://wiki.openjdk.java.net/display/CodeTools/jtreg

  9. https://docs.oracle.com/javacomponents/javatest-4-6/architect-guide/html/toc.htm

  10. https://openjdk.java.net/jtreg/index.html

  11. http://openjdk.java.net/jtreg/

  12. http://openjdk.java.net/jtreg/build.html

  13. https://docs.oracle.com/javase/specs/

  14. https://www.azul.com/downloads/zulu-embedded/

  15. https://www.azul.com/products/zulu-enterprise/jdk-comparison-matrix/

  16. https://hg.openjdk.java.net/aarch64-port/jdk8/

  17. http://cr.openjdk.java.net/~darcy/OpenJdkDevGuide/OpenJdkDevelopersGuide.v0.777.html   *

  18. https://bell-sw.com/pages/java-12.0.2/

  19. https://www.oracle.com/technetwork/java/javase/8-compatibility-guide-2156366.html

  20. https://wiki.openjdk.java.net/display/OpenJFX/Cross+Building+for+ARM+Hard+Float

  21. https://docs.oracle.com/javame/testing/testing.html

 

 

 

 

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐