Look at the code below:
data class Account(val username: String, val password: String)
fun setAccount(account: Account) {
print(account.username)
}
Check the code in Java format:
public static final class Account {
@NotNull
private final String username;
@NotNull
private final String password;
@NotNull
public final String getUsername() {
return this.username;
}
@NotNull
public final String getPassword() {
return this.password;
}
public Account(@NotNull String username, @NotNull String password) {
Intrinsics.checkParameterIsNotNull(username, "username");
Intrinsics.checkParameterIsNotNull(password, "password");
super();
this.username = username;
this.password = password;
}
@NotNull
public final String component1() {
return this.username;
}
@NotNull
public final String component2() {
return this.password;
}
@NotNull
public final Account copy(@NotNull String username, @NotNull String password) {
Intrinsics.checkParameterIsNotNull(username, "username");
Intrinsics.checkParameterIsNotNull(password, "password");
return new Account(username, password);
} ....
}public final void setAccount(@NotNull Account account) {
Intrinsics.checkParameterIsNotNull(account, "account");
String var2 = account.getUsername();
boolean var3 = false;
System.out.print(var2);
}
What’s the problem here ?
- Intrinsics.checkParameterIsNotNull() is generated
- The name of the argument are explored, “account”, “username” and “password”
Look at the obfuscated code:
public static final class C0374a { /* renamed from: a */
public final String f8550a; /* renamed from: b */
public final String f8551b; public C0374a(String str, String str2) {
C3818i.m15316b(str, "username");
C3818i.m15316b(str2, "password");
this.f8550a = str;
this.f8551b = str2;
} /* renamed from: a */
public final String mo12157a() {
return this.f8550a;
}
....}/* renamed from: a */
public final void mo12144a(C0374a aVar) {
C3818i.m15316b(aVar, "account");
System.out.print(aVar.mo12157a());
}
The Intrinsics.checkParameterIsNotNull() are still there.
Open mapping file in:
<project>\build\generated\outputs\mapping\<type>\mapping.txt
The classes in:
kotlin.jvm.internal.Intrinsics -> <your package>:
boolean areEqual(java.lang.Object,java.lang.Object) -> a
void checkExpressionValueIsNotNull(java.lang.Object,java.lang.String) -> a
java.lang.Throwable sanitizeStackTrace(java.lang.Throwable) -> a
java.lang.Throwable sanitizeStackTrace(java.lang.Throwable,java.lang.String) -> a
void throwNpe() -> a
void throwParameterIsNullException(java.lang.String) -> a
void checkParameterIsNotNull(java.lang.Object,java.lang.String) -> b
void throwUninitializedProperty(java.lang.String) -> b
void throwUninitializedPropertyAccessException(java.lang.String) -> ckotlin.jvm.internal.TypeIntrinsics -> <your package>:
java.util.Map asMutableMap(java.lang.Object) -> a
java.lang.Throwable sanitizeStackTrace(java.lang.Throwable) -> a
java.lang.ClassCastException throwCce(java.lang.ClassCastException) -> a
void throwCce(java.lang.Object,java.lang.String) -> a
void throwCce(java.lang.String) -> a
java.util.Map$Entry asMutableMapEntry(java.lang.Object) -> b
java.util.Map castToMap(java.lang.Object) -> c
java.util.Map$Entry castToMapEntry(java.lang.Object) -> d
How to get rid of them ?
Add the line below into proguard-rules.pro:
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
public static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
Summary:
- To follow the steps above to bypass the checking to increase the performance (must test the non-obfuscated version to ensure the app is working without the check)
- No non-onfuscated string are explored for hackers to save time to debug the app
- To decompile the app by yourself to see any method in Intrinsisc are used and add them into proguard-rules.pro !!