Skip to content

Conversation

@Earthcomputer
Copy link
Contributor

@Earthcomputer Earthcomputer commented Sep 30, 2025

Along with this, we now specify that the parameter indexes in the annotations.json file is the annotable parameter index, not the real parameter index. Previously, what this index referred to was vague and unspecified.

Here's an example of what javac generates for an enum constructor, where there are two synthetic parameters for the name and the ordinal:

enum Test {
  ;
  Test(@A String[] x, String a) {}
  @interface A {}
}
  // access flags 0x2
  // signature ([Ljava/lang/String;Ljava/lang/String;)V
  // declaration: void <init>(java.lang.String[], java.lang.String)
  private <init>(Ljava/lang/String;I[Ljava/lang/String;Ljava/lang/String;)V
    // parameter synthetic  <no name>
    // parameter synthetic  <no name>
    // parameter  <no name>
    // parameter  <no name>
    // annotable parameter count: 2 (invisible)
    @LTest$A;() // invisible, parameter 0

Here, the annotable parameter count is 2, which matches the number of non-synthetic parameters, as opposed to the number of parameters in the descriptor. The index for the parameter annotation is 0, because it is the 0th non-synthetic parameter, despite referring to parameter 2 in the descriptor.

@modmuss50 modmuss50 merged commit 7484a7f into FabricMC:exp/1.12 Sep 30, 2025
46 checks passed
@Earthcomputer Earthcomputer deleted the annotable-parameter-count branch September 30, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants