Hi there, have a QQ, let me know if this is not th...
# announcements
j
Hi there, have a QQ, let me know if this is not the right channel. By calling <string>.startsWith("$$"), I see some IllegalArgumentException reports coming from that: Caused by: java.lang.IllegalArgumentException: at kotlin.text.StringsKt__StringsJVMKt.b (StringsKt__StringsJVMKt.java) at kotlin.text.StringsKt__StringsJVMKt.startsWith$default (StringsKt__StringsJVMKt.java:195) I checked the code and dont see anything related and why this might be throwing such exception. Unfortunately I dont have a sample string that is causing the issue.
m
Are you calling that in Kotlin code or Java code? đŸ€”
j
calling from kotlin code
m
And I assume what you posted is the top of the stack trace and there is no additional comment? đŸ€” Like "Desired length -9000 is less than zero."?
j
That is correct
below that is just the class that actually called this and thats it.
k
Well what's at line
StringsJVMKt.java:195
?
Also is that the full stacktrace, not a part of it in the middle?
j
correct
StringsJVMKt.java:195 -> @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS") public actual fun String.startsWith(prefix: String, ignoreCase: Boolean = false): Boolean { if (!ignoreCase) return (this as java.lang.String).startsWith(prefix) else return regionMatches(0, prefix, 0, prefix.length, ignoreCase) }
k
I can't find anything, the only place
String
throws
IllegalArgumentException
is in the constructor when it encounters an invalid codepoints, and you're not constructing a string here.
j
exactly, i bumped into that method too
k
A test string would be great simple smile
i
IllegalArgumentException
can be thrown as a result of a failed null check of the incoming parameters: the receiver string or the prefix string.
j
fun unsubscribe(symbols: List<String>) { symbols.filterNot { it.startsWith("$$") }.forEach {
so you saying that an element in that list is
String?
?
if thats the case the call to unsubscribe would fail when passing the list param no? with the IllegalArgumentException
k
No you can't really typecheck the contents of a list at runtime, generics are erased.
j
hmm, true
This was very helpful, thank you all!