gson-comments/shrinker-test/common.pro

45 lines
1.3 KiB
Prolog
Raw Normal View History

### Common rules for ProGuard and R8
### Should only contains rules needed specifically for the integration test;
### any general rules which are relevant for all users should not be here but in `META-INF/proguard` of Gson
-allowaccessmodification
# On Windows mixed case class names might cause problems
-dontusemixedcaseclassnames
# Ignore notes about duplicate JDK classes
-dontnote module-info,jdk.internal.**
# Keep test entrypoints
-keep class com.example.Main {
public static void runTests(...);
}
-keep class com.example.NoSerializedNameMain {
Add shrinker-test examples with never-referenced constructors (#2478) * Add shrinker-test examples with never-referenced constructors R8 can do some optimizations that assume values of types whose constructors are never referenced are `null`. (A bit confused why the rules here are sufficient to avoid that optimization in the case of a class whose sole constructor has arguments and is unreferenced, since the keep rule only refers to `<init>()` instead of `<init>(...)`. Does R8 have special behavior for `<init>()` where attempting to keep that makes it assume a class is constructable even if it doesn't have a no-args constructor?) Also rename some test classes/names to refer to `NoArgs` instead of `Default` constructors. The examples here care about whether a no-argument constructor is present. While a no-argument constructor (explicitly defined or not) is used by default in some circumstances, the Java documentation consistently uses "default constructor" to refer only to constructors whose implementation is implicitly provided by the complier (all default constructors are no-argument constructors, but not vice versa). * Update shrinker-test/src/main/java/com/example/ClassWithNoArgsConstructor.java Accept review suggestion Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> * Update shrinker-test/src/main/java/com/example/NoSerializedNameMain.java Accept review suggestion Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> * Further adjust test class/method names for consistency * Update shrinker-test/src/main/java/com/example/NoSerializedNameMain.java Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> --------- Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2023-09-05 15:47:54 +02:00
public static java.lang.String runTestNoArgsConstructor();
public static java.lang.String runTestNoJdkUnsafe();
Add shrinker-test examples with never-referenced constructors (#2478) * Add shrinker-test examples with never-referenced constructors R8 can do some optimizations that assume values of types whose constructors are never referenced are `null`. (A bit confused why the rules here are sufficient to avoid that optimization in the case of a class whose sole constructor has arguments and is unreferenced, since the keep rule only refers to `<init>()` instead of `<init>(...)`. Does R8 have special behavior for `<init>()` where attempting to keep that makes it assume a class is constructable even if it doesn't have a no-args constructor?) Also rename some test classes/names to refer to `NoArgs` instead of `Default` constructors. The examples here care about whether a no-argument constructor is present. While a no-argument constructor (explicitly defined or not) is used by default in some circumstances, the Java documentation consistently uses "default constructor" to refer only to constructors whose implementation is implicitly provided by the complier (all default constructors are no-argument constructors, but not vice versa). * Update shrinker-test/src/main/java/com/example/ClassWithNoArgsConstructor.java Accept review suggestion Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> * Update shrinker-test/src/main/java/com/example/NoSerializedNameMain.java Accept review suggestion Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> * Further adjust test class/method names for consistency * Update shrinker-test/src/main/java/com/example/NoSerializedNameMain.java Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> --------- Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2023-09-05 15:47:54 +02:00
public static java.lang.String runTestHasArgsConstructor();
}
### Test data setup
# Keep fields without annotations which should be preserved
-keepclassmembers class com.example.ClassWithNamedFields {
!transient <fields>;
}
-keepclassmembernames class com.example.ClassWithExposeAnnotation {
<fields>;
}
-keepclassmembernames class com.example.ClassWithJsonAdapterAnnotation {
** f;
}
-keepclassmembernames class com.example.ClassWithVersionAnnotations {
<fields>;
}
# Keep the name of the class to allow using reflection to check if this class still exists
# after shrinking
-keepnames class com.example.UnusedClass