Collection field in record causes Class Format Error

Francois Green francois.green at gmail.com
Mon May 27 02:58:59 UTC 2019


public class Main {

    public static void main(String[] args) {
        var item = new Item(List.of());
    }
}

record Item(List<String> strings);


Exception in thread "main" java.lang.ClassFormatError: Field "strings" in
class Item has illegal signature "Ljava/util/List<Ljava/lang/String;>;"
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at
java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
        at
jdk.compiler/com.sun.tools.javac.launcher.Main$MemoryClassLoader.findClass(Main.java:657)
        at
jdk.compiler/com.sun.tools.javac.launcher.Main$MemoryClassLoader.loadClass(Main.java:594)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        at Main.main(CFE.java:6)


More information about the amber-dev mailing list