Skip to content

New RuleId value class mangled, preventing use in Java #2041

@magneticflux-

Description

@magneticflux-

Expected Behavior

I should be able to reference, use, and construct RuleIds from Java code.

Observed Behavior

I cannot access the third property of LintError (a RuleId). The generated bytecode shows that the name is mangled, per the docs:

  // access flags 0x11
  public final getRuleId-6XN97os()Ljava/lang/String;
  @Lorg/jetbrains/annotations/NotNull;() // invisible
   L0
    LINENUMBER 17 L0
    ALOAD 0
    GETFIELD com/pinterest/ktlint/rule/engine/api/LintError.ruleId : Ljava/lang/String;
    ARETURN
   L1
    LOCALVARIABLE this Lcom/pinterest/ktlint/rule/engine/api/LintError; L0 L1 0
    MAXSTACK = 1
    MAXLOCALS = 1

This can be fixed by explicitly specifying the name with @JvmName.

Your Environment

  • Version of ktlint used: 0.49.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions