Class MixedInMetaClass

All Implemented Interfaces:
GroovyObject, MetaClass, MetaObjectProtocol, MutableMetaClass

public class MixedInMetaClass extends OwnedMetaClass
A delegating MetaClass that allows mixing in a mixin object. This class delegates method invocation to an owner object's MetaClass while maintaining a weak reference to the owner to prevent memory leaks.

This implementation is for internal use by the Groovy runtime's mixin feature.

  • Constructor Details

    • MixedInMetaClass

      public MixedInMetaClass(Object instance, Object owner)
      Constructs a new MixedInMetaClass.
      Parameters:
      instance - the instance that will have the mixin applied
      owner - the owner object that provides the mixin functionality
  • Method Details

    • getOwner

      protected Object getOwner()
      Description copied from class: OwnedMetaClass
      Returns the owner object whose MetaClass should be used for delegated operations.
      Specified by:
      getOwner in class OwnedMetaClass
      Returns:
      the owner object
    • getOwnerMetaClass

      protected MetaClass getOwnerMetaClass(Object owner)
      Description copied from class: OwnedMetaClass
      Returns the MetaClass of the owner object.
      Specified by:
      getOwnerMetaClass in class OwnedMetaClass
      Parameters:
      owner - the owner object
      Returns:
      the owner's MetaClass
    • invokeMethod

      public Object invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass)
      Description copied from class: OwnedMetaClass
      Invokes a method on the owner's MetaClass with caller context.
      Specified by:
      invokeMethod in interface MetaClass
      Overrides:
      invokeMethod in class OwnedMetaClass
      Parameters:
      sender - the class making the request
      receiver - the receiver object (ignored; the owner is used instead)
      methodName - the method name
      arguments - the method arguments
      isCallToSuper - whether this is a super method call
      fromInsideClass - whether this is called from inside the class
      Returns:
      the method result