JDK-8338547 : Sharing of singleton instructions in ClassFile building
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.classfile
  • Affected Version: 24
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-08-19
  • Updated: 2024-08-19
Description
Discovered by [~redestad], we should share singleton instructions in ClassFile building in addition to in parsing.

Also note that switching over enums will generate synthetic classes to support separate compilation. We should move all such switches into a single class, presumably BytecodeHelpers.
Comments
We should also investigate the opposite alternative - avoid singleton instructions also in ClassFile transforms. Singleton instructions actually prevents the instruction use as identities for linking custom user data with specific instruction (for example in a hash map). Performance impact of the singleton instructions should be benchmarked and we should decide to go one way or the other in the whole API.
19-08-2024