Thursday, June 9, 2022

Java base libraries

The Java base module is already the largest module in the JDK, with the Desktop module being the only one that comes close to its scale, so it makes sense to split off some base libraries from the base module so it doesn't get even bigger. There are almost as many base libraries in Java SE outside the base module as in it.

The basic idea is that modules are moved outside of java.base provided that they contain some technical specification or format that isn't strictly necessary to the foundations of Java. XML, for example, is a very specialized format which doesn't need to be in java.base. Similarily for HTTP, which is moved to its own separate module.

Language extensions

The Java SE platform actually provides quite a lot of language capabilities aside from those in java.base. These come in the form of three different APIs:
  • The Java compiler API
  • Java management extensions
  • Instrumentation
The Java compiler API defines a language model for Java and defines its various types and elements as classes with Java itself. It also defines a compiler API so that a compiler can be invoked from within Java itself. In addition, it provides facilities for processing annotations.

The instrumentation module allows you to instrument programs running on the JVM. In particular, it defines the ClassFileTransformer class which lets you transform the bytecodes of Java methods running on the JVM. The ClassFileTransformer can be added to an agent using the addTransformer method of the Instrumentation interface. This is clearly deeply linked to the JVM and its bytecode format in its implementation, but it is not needed in java.base.

Finally, there is a whole host of management extensions provided by JMX. All of these are based upon the concept of managed bean which is defined with the purpose of monitoring some kind of object on the JVM. An MBean is not a Java bean in the sense of the desktop module, but it gets the name from the fact that MBeans have similar properties to beans like their getters and setters.

Utilities

Java SE provides additional utilities in two separate single-package modules:
  • Logging: in the java.util.logging package
  • Preferences: in the java.util.prefs package
Logging and preferences are clearly utilities as demonstrated by their package names. Logging lets you log events as they occur in the course of your program. The preferences package on the other handle is defined by a single class Preferences which lets you store preference data using maps that map Strings to Strings.

Networking extensions

There is a single package in Java SE, contained in its own module, for dealing with HTTP. It builds upon the java.net package in java.base. It is useful in Java applications that need to interact with web pages.

Security

The Java SE platform provides support for two different security protocols defined by the IETF: namely SASL and GSS. These are both comparatively small modules, but it isn't necessary to include them with the Java security API provided by java.base.

XML

The java.xml module is the third largest module in the Java SE platform because it provides such a wide array of functionality like SAX, StaX, JAXP, and the DOM. Another module in Java SE defines XML cryptography.

Previously
Overview of the Java Base module
Overview of the Java XML module

No comments:

Post a Comment