Class PrimitiveTypeAwareAssigner

java.lang.Object
net.bytebuddy.implementation.bytecode.assign.primitive.PrimitiveTypeAwareAssigner
All Implemented Interfaces:
Assigner

@Enhance public class PrimitiveTypeAwareAssigner extends Object implements Assigner
This assigner is able to handle non-void, primitive types. This means:
  1. If a primitive type is assigned to a non-primitive type, it will attempt to widen the source type into the target type.
  2. If a primitive type is assigned to a non-primitive type, it will attempt to box the source type and then query the chained assigner for assigning the boxed type to the target type.
  3. If a non-primitive type is assigned to a primitive type, it will unbox the source type and then attempt a widening of the unboxed type into the target type. If the source type does not represent a wrapper type, it will attempt to infer the boxing type from the target type and check if the source type is assignable to this wrapper type.
  4. If two non-primitive types are subject of the assignment, it will delegate the assignment to its chained assigner.
  • Field Details

    • referenceTypeAwareAssigner

      private final Assigner referenceTypeAwareAssigner
      Another assigner that is aware of assigning reference types. This assigner is queried for assigning non-primitive types or for assigning a boxed type to another non-primitive type.
  • Constructor Details

    • PrimitiveTypeAwareAssigner

      public PrimitiveTypeAwareAssigner(Assigner referenceTypeAwareAssigner)
      Creates a new assigner with the given delegate.
      Parameters:
      referenceTypeAwareAssigner - A chained assigner that is queried for assignments not involving primitive types.
  • Method Details

    • assign

      Specified by:
      assign in interface Assigner
      Parameters:
      source - The original type that is to be transformed into the targetType.
      target - The target type into which the sourceType is to be converted.
      typing - A hint whether the assignment should consider the runtime type of the source type, i.e. if type down or cross castings are allowed. If this hint is set, this is also an indication that void to non-void assignments are permitted.
      Returns:
      A stack manipulation that transforms the sourceType into the targetType if this is possible. An illegal stack manipulation otherwise.