@@ -684,7 +684,9 @@ public static long generateEEAFiles(final Config cfg) throws IOException {
684684 // do nothing
685685 } else {
686686 assert inheritedFrom != null ;
687- if (inheritableAnnotatedSignature .value .equals (member .annotatedSignature .value )) {
687+ if (member .annotatedSignature .comment .contains ("@Keep" )) {
688+ // do nothing
689+ } else if (inheritableAnnotatedSignature .value .equals (member .annotatedSignature .value )) {
688690 if (setInheritedAnnotatedSignature (member , inheritableAnnotatedSignature , inheritedFrom .getName ())) {
689691 recomputeInheritance .set (true );
690692 }
@@ -843,12 +845,18 @@ public static long validateEEAFiles(final Config config) throws IOException {
843845 // ensure the EEA file does not contain declarations of non-existing fields/methods
844846 parsedEEAFile .getClassMembers ().forEach (parsedMember -> {
845847 if (computedEEAFile .findMatchingClassMember (parsedMember ) == null ) {
848+
849+ // allow non-existing fields/method declarations if they are annotated with @Keep
850+ // for compatibility to support older versions of a class
851+ if (parsedMember .annotatedSignature .comment .contains ("@Keep" ))
852+ return ;
853+
846854 final var candidates = computedEEAFile .getClassMembers () //
847855 .filter (m -> m .name .equals (parsedMember .name )) //
848856 .map (m -> m .name + "\n " + " " + m .originalSignature ) //
849857 .collect (Collectors .joining ("\n " ));
850858 throw new IllegalStateException ("Unknown member declaration found in [" + path + "]:\n " + parsedMember + (candidates
851- .length () > 0 ? "\n Potential candidates: \n " + candidates : "" ));
859+ .isEmpty () ? "" : "\n Potential candidates: \n " + candidates ));
852860 }
853861 });
854862 });
0 commit comments