4

I'm learning Java 17, and with JEP334 (JVM Constants API), I know how to get ClassDesc, MethodTypeDesc, MethodHandleDesc, DynamicConstantDesc.

But what can these objects do?

In what application scenarios do I need these objects?

Lii
  • 11,553
  • 8
  • 64
  • 88
musan
  • 51
  • 6

1 Answers1

6

This library is intended to to be used by low-level libraries, such as bytecode parsing and generation APIs like ASM, reflection libraries, etc. Most Java developers will not need to use this.

Brian Goetz
  • 90,105
  • 23
  • 150
  • 161
  • Can you provide sample code or pseudocode, I don't really understand how to do this, I need code to understand – musan Jan 20 '22 at 01:46
  • 2
    @musan this API is *intended* to be used by certain libraries. This does not imply that these libraries are already supporting it. So there is no example code to provide. – Holger Jan 20 '22 at 09:57
  • 2
    The initial (now-removed) class generation I wrote for the `jextract` tool used the API pretty extensively: https://github.com/JornVernee/panama-foreign/blob/aa60472b0c9a3eb8bfb315739ec0b524b1fa3cbe/src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/ConstantHelper.java We ended up moving away from it mostly since IntelliJ couldn't decompile those class files, and because most users preferred generating source code (and there's no language support for condy atm). – Jorn Vernee Jan 21 '22 at 18:31