Collection field in record causes Class Format Error
Vicente Romero
vicente.romero at oracle.com
Fri Aug 2 23:18:25 UTC 2019
Hi Francois,
I'm not seeing this issue in the current version of the records branch.
Could you please update to the latest version and double check if the
issue disappears?
Thanks,
Vicente
On 7/31/19 9:32 PM, Brian Goetz wrote:
> The issue here is not the Collection but the generics. The compiler is not erasing the type before it lowers the record into its desugared form.
>
>> On May 26, 2019, at 7:58 PM, Francois Green <francois.green at gmail.com> wrote:
>>
>> 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