EsotericSoftware / reflectasm

High performance Java reflection
BSD 3-Clause "New" or "Revised" License
1.53k stars 222 forks source link

Scala 3 lazy val implementation breaks FieldAccess reflection #86

Open nvollmar opened 2 years ago

nvollmar commented 2 years ago

Scala 3 changed the implementation of lazy vals. Classes containing a lazy val end up with a field called 0bitmap$1:

Compiled from "Test.scala"
public class Test implements scala.Product,java.io.Serializable {
  public static final long OFFSET$0;
  public long 0bitmap$1;
  private final byte a;
  ...

This results in a ClassFormatError:

Cause: java.lang.ClassFormatError: Illegal field name "0bitmap$1" in class io/altoo/akka/serialization/kryo/TestFieldAccess
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
    at com.esotericsoftware.reflectasm.AccessClassLoader.defineClass(AccessClassLoader.java:78)
    at com.esotericsoftware.reflectasm.AccessClassLoader.defineAccessClass(AccessClassLoader.java:57)
    at com.esotericsoftware.reflectasm.FieldAccess.get(FieldAccess.java:173)

(Report from https://github.com/EsotericSoftware/kryo/issues/882)