Java would get an API for processing Java class files, under a proposal afoot in the Java local community.

The draft classfile API proposal calls for provision of an API for parsing, creating, and reworking Java course documents. This classfile library to begin with would provide as an interior substitute for the ASM Java bytecode manipulation framework. Eventually, ASM would be removed fully from the JDK.

The classfile API proposal notes that course file era, parsing, and instrumentation are ubiquitous in the Java ecosystem, with many instruments and libraries needing to process course information. Frameworks normally accomplish on-the-fly bytecode instrumentation. The JDK, the proposal states, need to deliver an exact, finish, up-to-day, performant API for looking at, producing, and transforming Java class documents.

Structure objectives and rules for the API include things like having all class file entities, this sort of as strategies and fields, represented by immutable objects. User-driven navigation also is a aim. Motivating the get in touch with for a Java classfile library are factors which include:

  • JDK consolidation, with the JDK itself considerable in dealing with class data files. And there is a delay inherent in the JDK’s use of ASM.
  • Variation skew involving frameworks and functioning the JDK. Programs and frameworks processing class documents generally bundle a classfile library this kind of as ASM. But simply because new course file features can seem in any release of the JDK, apps and frameworks are extra often encountering class information that are more recent than the library they are bundled with, resulting in runtime problems or in frameworks making an attempt to parse course file formats from the foreseeable future. Builders want a classfile library that will be up-to-date with jogging the JDK.
  • The JVM and course file format now are evolving quicker than right before. Though some evolutions are simple, some others are additional advanced, this sort of as Challenge Valhalla bringing forth new bytecodes, field descriptors, and verification regulations.
  • The language has enhanced substantially given that ASM was written.

Options get in touch with for initially replacing ASM as a runtime dependency of the JDK without unacceptable reduction of overall performance. One more target would be to exchange the inside classreader library made use of by the compiler and JDK instruments. Sooner or later, a vary of frameworks and applications should really be capable to use the library as an alternate to ASM, cglib, and other bytecode libraries.

Copyright © 2022 IDG Communications, Inc.