#457 Proguard doesn't keep classes passed to annotations

Shrinking (3)
David Reiss

See sample code at https://gist.github.com/3881844

The "Experiment" class is passed to MyAnnotation, which is kept due to "-keepattributes *Annotation*", but Experiment is not kept, and we get an error when trying to call .type().


  • Eric Lafortune

    Eric Lafortune - 2012-10-15

    Thanks for the detailed report. I can reproduce the problem. A relevant part of the annotation is removed indeed. I'll look into it.

  • Eric Lafortune

    Eric Lafortune - 2012-10-15
    • assigned_to: nobody --> lafortune
    • priority: 5 --> 6
    • status: open --> open-accepted
  • Eric Lafortune

    Eric Lafortune - 2012-10-15

    I have modified the code for the upcoming ProGuard 4.9 beta2, so it keeps the Experiment class and the annotation "type = Experiment.class". However, the sample code also calls "newInstance()" on the Experiment class, which is a kind of reflection that ProGuard can't foresee. You'll still have to specify
    -keep class pg.Experiment
    This historically also preserves the parameterless constructor, required for this case. Now, this configuration already solves the issue for ProGuard 4.8, so the fix may have limited added value.

  • David Reiss

    David Reiss - 2012-10-15

    Good point about newInstance. I've updated the code to stop using newInstance (the original code is still available at https://gist.github.com/3881844/4f1c1b968ea94fe4bd7dc1d80963fab50c811c7f ).

    If you want to tell me how to get the trunk version of Proguard (I couldn't find the source myself), I can test it out to make sure it works on this code with no config changes.

  • Eric Lafortune

    Eric Lafortune - 2012-10-17

    I don't have an on-line repository. I'll try to get version 4.9 beta2 out quickly.

  • Eric Lafortune

    Eric Lafortune - 2013-12-27
    • status: open-accepted --> closed-fixed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks