I'm having a super weird behavior from a code that I was testing. The test I wrote was to see the behavior of the class if the Android returned an empty package name. After some debugging, I found this (consider that packageName is empty):
val resultFromKotlin = packageName.isNullOrEmpty()
val resultFromJava = StringUtils.isEmpty(packageName)
Is this expected? Can someone tell what the deal with this?
ps1.: In the picture above, Android Studio was complaining of isNullOrEmpty saying that could be simplified since packageName can't be null at that point.
ps2.: For references:
The StringUtils class is written in Java as follow:
public static boolean isEmpty(String str) {
return str == null || TextUtils.isEmpty(str.trim());
}
TextUtils is also from Java, but it's part of Android library:
public static boolean isEmpty(@Nullable CharSequence str) {
return str == null || str.length() == 0;
}
This is how kotlin implements it's extension method:
public inline fun CharSequence?.isNullOrEmpty(): Boolean {
contract {
returns(false) implies (this@isNullOrEmpty != null)
}
return this == null || this.length == 0
}
EDIT 08/11/2018:
Just for clarification, my problem is the wrong value returned from Java, not searching for an equivalence in the test, also:

