31

Notes on the Java Platform

 5 years ago
source link: https://www.tuicool.com/articles/hit/V7BN7nn
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Summary

Notes on the Java platform.

Overview

These are notes on the Java platform and tools.

Specifications

  • The Java Language
  • The Java Virtual Machine
  • Java Platform

Each Java Specification Request (JSR) includes a Technology Compatibility Kit (TCK) that enables developers to test that an implementation meets the specifications of the JSR.

Similarly, the Java Compatibility Kit (JCK) tests that Java Platform implementations are compatible with standards.

The Java Virtual Machine

Each Java Virtual Machine (JVM) runs compiled binary Java bytecode . This bytecode is platform-independent. Bytecode is enclosed in .class files.

Components of the JVM

  • Compiler - Interprets bytecode, and automatically applies JIT compilation (using C1 fast compiler and C2 optimized compiler)
  • Runtime - Loads class files into memory, concurrency, interacts with the operating system (threads, memory allocation, sockets), works with external monitoring, handles logging
  • Garbage Collector - Memory management

Garbage Collector

G1 is now the default garbage collector for OpenJDK 10 and above. It implements a parallel mark-sweep-compact algorithm. The default pause time goal for G1 is 200 milliseconds, but this is adjustable.

Java ARchives (JARs)

Java ARchive (JAR) files enable you to ship many class files inside a single compressed file. A JAR can also contain other types of files, such as the HTML, CSS and JavaScript for a Web application.

A JAR is a ZIP file archive that should contain a directory named META-INF , and inside that a manifest file, which will be named MANIFEST.MF . The manifest file provides data about the files that are contained in the JAR.

Java Class Loaders

The JVM does not find classes itself. Instead, Java Class Loaders look for the appropriate class file when the class is first used. By default, a JVM will use three class loaders: the boot class loader (for core libraries that are supplied with the JVM), the extension class loader (for libraries in the extensions directory), and a system class loader , which looks on the classpath , a list of directories and JARs. A classpath can specify any combination of directories, paths to individual JARs, and paths with wildcards to load multiple JARs. Web application servers use additional class loaders. The boot class loader is written in platform-specific native code, and all other class loaders are written in Java.

Agents

Agents are plugins for the JVM. For example, JRebel is an agent that enables hot-code reloading.

Java Distributions

Each distribution of Java includes a Java Virtual Machine (JVM), and a Java Developers Kit (JDK) which provides the tools and class libraries. Compatibility tests verify whether distribution comply with Java standards.

Most distributions use the HotSpot JVM. For example, both Amazon Corretto and Azul Zulu include versions of the HotSpot JVM. OpenJ9 is an alternative Open Source JVM that is maintained by IBM and the Eclipse Foundation. Most Java distributions now use versions of the OpenJDK tools and libraries.

Android uses the Java language, but Android software development kits (SDKs) are not fully compatible with Java standards.

Free, Open Source Distributions

  • AdoptOpenJDK - Provides free versions of the OpenJDK with either HotSpot or OpenJ9 Java Virtual Machines
  • Amazon Corretto - OpenJDK with HotSpot Java Virtual Machine, supported by AWS
  • Eclipse OpenJ9 - OpenJDK with the OpenJ9 JVM
  • Red Hat OpenJDK - Java distributions for JBoss users (Linux and Windows only)
  • SapMachine - OpenJDK and JVM, provided by SAP for their customers
  • Zulu - OpenJDK with the Zulu JVM, maintained by Azul Systems

Proprietary Distributions

  • IBM Java SDK
  • JamaicaVM - A proprietary Java implementation for real-time systems.
  • Oracle JDK - Proprietary builds of HotSpot and OpenJDK, supported by Oracle
  • Zing - High-performance proprietary Java implementation maintained by Azul Systems

Standard Tools

OpenJDK packages include a JVM (such as HotSpot or OpenJ9), a standard library (the Java Class Library ), and various tools, including:

  • javac compiler turns .java source files into .class files.
  • javap de-compiler reads the contents of class files.
  • jar tool works with .jar files, which contain the compiled .class files.
  • jarsigner tool is for digitally signing JAR files.
  • jdb is a command-line debugging client for the JVM
  • jshell command-line shell, which was introduced in Java 9.
  • jlink tool create image files that include both code modules and a Java run-time. This was introduced in Java 9.

JDK 9 introduced jaotc , an experimental alternative compiler to javac that produces Ahead Of Time Compiled code, rather than generic bytecode. This is based on Graal .

Monitoring and Debugging

Java Virtual Machines accept connections from debuggers, which may either be on the same system, or connecting from a remote system. The OpenJDK includes jdb , a command-line debugger, and IDEs for Java include graphical debuggers.

Java Flight Recorder and Java Mission Control provide a data collection and profiling system for the OracleJDK.

Popular Third-Party Software

Build Tools

Testing Tools


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK