Class NestmateAccessorGenerator

java.lang.Object
dev.morphia.critter.parser.generator.NestmateAccessorGenerator

public class NestmateAccessorGenerator extends Object
Generates a PropertyAccessor implementation that uses direct getfield/putfield (for fields) or invokevirtual (for getter/setter methods) to access entity properties. The generated class must be defined as a hidden nestmate of the entity class so the JVM grants it private-member access.

Array-typed properties are not supported: the BSON codec provides Object[] at runtime, which is incompatible with putfield to a typed array field. Callers should throw to trigger CritterMapper fallback to reflection for such entities.

  • Constructor Details

    • NestmateAccessorGenerator

      public NestmateAccessorGenerator(Class<?> entity, FieldInfo field)
    • NestmateAccessorGenerator

      public NestmateAccessorGenerator(Class<?> entity, MethodInfo method)
  • Method Details

    • generate

      public byte[] generate()
      Generates the accessor bytecode.
      Throws:
      IllegalArgumentException - if the property type is an array (BSON codec provides Object[] which is incompatible with typed array putfield at runtime)