Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Records in jlink:ed application throws exception

Using records (preview feature java-14) in a jlink:ed application, gives below error when using options:

options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']

java.lang.ClassFormatError: Invalid constant pool index 11 for name in Record attribute in class file 
myproj/MyClass$MyRecord
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
    at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
like image 215
Aksel Willgert Avatar asked Apr 29 '20 15:04

Aksel Willgert


2 Answers

I suggest you to try with JDK-15 which has an updated version of ASM (ASM 8.0.1) which have support for records. That should fix your issue. This is the bug report that relates to the update to ASM (ASM 8.0.1): JDK-8241627. This version of ASM was not available while we were developing JDK 14. I've never seen a backport of ASM to a previous JDK version, and considering that records are a preview feature...

like image 107
Vicente Romero Avatar answered Sep 20 '22 14:09

Vicente Romero


I can reproduce this issue with a simple "hello world" module that uses record feature along with JDK-14.

On the other hand with JDK-15 build (built from the source repo), it just works fine.

like image 41
A. Sundararajan Avatar answered Sep 19 '22 14:09

A. Sundararajan