10 May 2018

New Classes in Java 9

JigsawJava 10 was released few months ago, marking the end of free public updates for Java 9 at the same time. High time to have a look what is new in Java 9. Like for Java 8 and Java 7 before, I follow the same approach and list the new classes shipped in the release. I use my JavaClass Ruby gem to find all public classes. There were two minor additions to the Java class file format which I hade to deal with: Two new constant pool tags (Module 19 and Module 20) and a new access modifier (Module 0x8000).

Java Platform Module System (JPMS)
Java Modularity aka Project Jigsaw is probably the biggest change in Java 9, outlined by JEP 261. It brings the following classes for modules, tools and SPI providers necessary to decouple modules.
java.lang.instrument.UnmodifiableModuleException
java.lang.LayerInstantiationException
java.lang.Module
java.lang.ModuleLayer

java.lang.module.Configuration
java.lang.module.FindException
java.lang.module.InvalidModuleDescriptorException
java.lang.module.ModuleDescriptor
java.lang.module.ModuleFinder
java.lang.module.ModuleReader
java.lang.module.ModuleReference
java.lang.module.ResolutionException
java.lang.module.ResolvedModule

javax.lang.model.element.ModuleElement
javax.lang.model.element.UnknownDirectiveException

jdk.tools.jimage.Main
jdk.tools.jimage.resources.jimage

jdk.tools.jlink.builder.DefaultImageBuilder
jdk.tools.jlink.builder.ImageBuilder
jdk.tools.jlink.plugin.Plugin
jdk.tools.jlink.plugin.ResourcePool
jdk.tools.jlink.plugin.ResourcePoolBuilder
jdk.tools.jlink.plugin.ResourcePoolEntry
jdk.tools.jlink.plugin.ResourcePoolModule
jdk.tools.jlink.plugin.ResourcePoolModuleView

jdk.tools.jmod.JmodTask
jdk.tools.jmod.Main

java.net.spi.URLStreamHandlerProvider
java.util.spi.AbstractResourceBundleProvider
java.util.spi.ResourceBundleProvider
java.util.spi.ToolProvider
javax.accessibility.AccessibilityProvider
jdk.nio.zipfs.ZipFileSystemProvider
Reactive Streams
JEP 266 is quite interesting, it adds the Flow API, a minimal API version of Reactive Streams:
java.util.concurrent.Flow
java.util.concurrent.Flow$Processor
java.util.concurrent.Flow$Publisher
java.util.concurrent.Flow$Subscriber
java.util.concurrent.Flow$Subscription
Other Smaller Changes
Then we have BeanInfo Annotations which allows us to use annotations to provide BeanInfo information. Now it is possible to Filter Incoming Serialization Data which fixes a security vulnerability and we get XML Catalogs.
java.beans.BeanProperty
java.beans.JavaBean
javax.swing.SwingContainer

java.io.ObjectInputFilter
java.io.ObjectInputFilter$Config
java.io.ObjectInputFilter$FilterInfo
java.io.ObjectInputFilter$Status

javax.xml.catalog.Catalog
javax.xml.catalog.CatalogException
javax.xml.catalog.CatalogFeatures
javax.xml.catalog.CatalogManager
javax.xml.catalog.CatalogResolver
UI Related Changes
I thought Java on the fat client side is not a thing, but there are a bunch of UI related JEPs: New Platform-Specific Desktop Features, support for Multi-Resolution Images, TIFF Image I/O and even some changes to good old Swing:
java.awt.desktop                  java.awt.image
...AboutEvent/-Handler            ...AbstractMultiResolutionImage
...AppEvent                       ...BaseMultiResolutionImage
...AppForegroundEvent/-Listener   ...MultiResolutionImage
...AppHiddenEvent/-Listener
...AppReopenedEvent/-Listener     javax.imageio.plugins.tiff
...FilesEvent                     ...BaselineTIFFTagSet
...OpenFilesEvent/-Handler        ...ExifGPSTagSet
...OpenURIEvent/-Handler          ...ExifInteroperabilityTagSet
...PreferencesEvent/-Handler      ...ExifParentTIFFTagSet
...PrintFilesEvent/-Handler       ...ExifTIFFTagSet
...QuitEvent/-Handler             ...FaxTIFFTagSet
...QuitResponse                   ...GeoTIFFTagSet
...QuitStrategy                   ...TIFFDirectory
...ScreenSleepEvent/-Listener     ...TIFFField
...SystemEventListener            ...TIFFImageReadParam
...SystemSleepEvent/-Listener     ...TIFFTag
...UserSessionEvent/-Listener     ...TIFFTagSet

java.awt.Taskbar                  javax.swing.plaf.synth.SynthIcon
java.awt.peer.TaskbarPeer         javax.swing.UIClientPropertyKey
Incubator HTTP 2 Client
Java 9 introduces the concept of an incubator area, where Oracle wants to try out new features. There we have a new HTTP 2 Client,
jdk.incubator.http.HttpClient
jdk.incubator.http.HttpHeaders
jdk.incubator.http.HttpRequest
jdk.incubator.http.HttpResponse
jdk.incubator.http.HttpTimeoutException
jdk.incubator.http.MultiMapResult
jdk.incubator.http.WebSocket
jdk.incubator.http.WebSocketHandshakeException
As it is not a final API it might change in future Java releases.

Other changes
There is The Java Shell (Read-Eval-Print Loop) (main class jdk.jshell.JShell) and the Parser API for Nashorn. The Doclet API jas been moved from com.sun. to jdk.javadoc.doclet and the jdk.​dynalink package enables Dynamic Linking of Language-Defined Object Models - I have no idea what that is for ;-)

Finally there is a bunch of individual classes implementing Indify String Concatenation, Variable Handles, Process API Updates, the New Version-String Scheme, the Stack-Walking API, Platform Logging API and Service, the usual security updates like DRBG-Based SecureRandom Implementations, Merge Selected Xerces 2.11.0 Updates into JAXP and even some additions to CORBA.
java.lang.invoke.StringConcatFactory
java.lang.invoke.StringConcatException

java.lang.invoke.VarHandle

java.lang.IllegalCallerException
java.lang.ProcessHandle
java.lang.ref.Cleaner
java.lang.reflect.InaccessibleObjectException
java.lang.Runtime$Version
java.lang.StackWalker
java.lang.System$Logger

java.sql.ConnectionBuilder
java.sql.ShardingKey/-Builder
javax.sql.PooledConnectionBuilder
javax.sql.XAConnectionBuilder

java.util.concurrent.SubmissionPublisher
java.util.zip.CRC32C
jdk.nio.zipfs.ZipInfo

javax.annotation.processing.Generated
javax.management.ConstructorParameters
javax.tools.StandardJavaFileManager$PathFactory

java.security.cert.URICertStoreParameters
java.security.DrbgParameters
java.security.SecureRandomParameters
javax.security.auth.kerberos.EncryptionKey
javax.security.auth.kerberos.KerberosCredMessage
jdk.security.jarsigner.JarSigner
jdk.security.jarsigner.JarSignerException

javax.xml.bind.JAXBContextFactory
javax.xml.xpath.XPathEvaluationResult
javax.xml.xpath.XPathNodes
org.w3c.dom.ElementTraversal

org.omg.CORBA.BoundsHelper
org.omg.CORBA.ORBPackage.InvalidNameHelper
org.omg.CORBA.TypeCodePackage.BadKindHelper
org.omg.CORBA.TypeCodePackage.BoundsHelper
To learn more about Java 9
The list above shows new classes only. There are many more changes in Java 9. I recommend watching Venkat Subramaniam's Exploring Java 9 The Key Parts talk from Devoxx 2017. The recording contains more than two and a half hours material presented in Venkat's dry and at the same time entertaining way. It is the most complete presentation on new features in Java 9 which I found. A big part of it is about using JShell and Jigsaw. It is an amazing talk. Go watch it.

Summary
Java 9 contains around 500 new classes, similar to Java releases 6, 5 and 1.2. You can download the complete list of all classes available in Java from version 1.0 to 9.0.4. Each class name is annotated with [release] showing the release it first appeared, e.g. java.lang.annotation.Annotation [5].