Class ModifierUtils

java.lang.Object
io.micronaut.sourcegen.bytecode.core.ModifierUtils

@Internal public final class ModifierUtils extends Object
Maps Java model modifiers to JVMS access flags without depending on a bytecode library.

The integer values are the class-file values defined by the JVMS and are understood by both the ASM and JDK ClassFile backends.

Since:
2.2
  • Field Details

  • Method Details

    • memberFlags

      public static int memberFlags(Set<Modifier> modifiers)
      Maps member modifiers.
      Parameters:
      modifiers - Java modifiers
      Returns:
      JVMS flags
    • objectFlags

      public static int objectFlags(ObjectDef objectDef)
      Maps an object definition to its class-file flags.
      Parameters:
      objectDef - The definition
      Returns:
      JVMS flags
    • classFlags

      public static int classFlags(Set<Modifier> modifiers, @Nullable ClassTypeDef outerType)
      Maps the class-file flags of a class being emitted. Visibility and static are represented by the enclosing InnerClasses entry instead of the class-file access field.
      Parameters:
      modifiers - Declared modifiers
      outerType - Enclosing type, or null
      Returns:
      JVMS class flags
    • innerClassFlags

      public static int innerClassFlags(ObjectDef objectDef, boolean declaredInterface)
      Maps the flags carried by an InnerClasses entry.
      Parameters:
      objectDef - The nested definition
      declaredInterface - Whether the enclosing type is an interface
      Returns:
      JVMS flags
    • accessFlags

      public static int accessFlags(Set<Modifier> modifiers)
      Maps the access modifiers alone - public, protected and private - as a member that takes the access of its definition, the implicit canonical constructor of a record, is written.
      Parameters:
      modifiers - Java modifiers
      Returns:
      JVMS access flags
      Since:
      2.3
    • methodFlags

      public static int methodFlags(MethodDef method)
      Maps the flags of a method: its modifiers, and ACC_SYNTHETIC for a synthetic one.
      Parameters:
      method - The method
      Returns:
      JVMS flags
      Since:
      2.3
    • fieldFlags

      public static int fieldFlags(ObjectDef objectDef, FieldDef field)
      Maps the flags of a field: its modifiers, ACC_SYNTHETIC for a synthetic one and ACC_ENUM for the constant of an enum.
      Parameters:
      objectDef - The definition declaring the field, in its lowered class form for an enum
      field - The field
      Returns:
      JVMS flags
      Since:
      2.3
    • parameterFlags

      public static int parameterFlags(ParameterDef parameter)
      Maps the flags of a method parameter, as the MethodParameters attribute carries them.
      Parameters:
      parameter - The parameter
      Returns:
      JVMS flags
      Since:
      2.3
    • classFileFlags

      public static int classFileFlags(ObjectDef objectDef, @Nullable ClassTypeDef outerType)
      Maps the flags of the class file of a definition: the kind of type it is, its class flags, ACC_SYNTHETIC for a synthetic one and ACC_ENUM for the lowered class form of an enum. A record is final; the Record attribute, not a flag, marks it as a record.
      Parameters:
      objectDef - The definition, in its lowered class form for an enum
      outerType - The enclosing type, or null
      Returns:
      JVMS class flags
      Since:
      2.3