Skip to content

Proguard incorrectly backports default interface method parameter annotations #451

@Berstanio

Description

@Berstanio

A simple setup reproduces the issue:

@Target({ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface RuntimeAnnotation {
}
public class ImplementingClass implements DefaultInterface {}
public interface DefaultInterface {
    default void something(@RuntimeAnnotation String par) {}
}

Processing this with these proguard flags:

-dontshrink
-dontobfuscate
-dontoptimize
-dontwarn
-dontnote

-target 7
-allowaccessmodification

Will result in the following desugared method:

  public void something(java.lang.String);
    descriptor: (Ljava/lang/String;)V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=0, locals=2, args_size=2
         0: return
      LineNumberTable:
        line 8: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       1     0  this   Lde/test/DefaultInterface;
            0       1     1   par   Ljava/lang/String;
    RuntimeVisibleParameterAnnotations:
}

Which is clearly incorrect. It not only omits the parameter annotations, but it also emits an invalid section that will result in a java.lang.annotation.AnnotationFormatError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions