Hi! Can I access `<http://java.io|java.io>.InputSt...
# announcements
g
Hi! Can I access
<http://java.io|java.io>.InputStream
in Kotlin? When I converted Java class(that had
InputStream
type field) to Kotlin that field was accessible in Kotlin, but when I created a new Kotlin class in Kotlin project InputStream was not accessible like it's presented on screenshot.
m
Is your project configured as a JVM-project?
v
If you target the JVM, you can by having the jvm stdlib as dependency. Actually if you did not declare any stdlib dependency the correct one should be added automatically.
At least when using Gradle and Kotlin 1.4
g
It is Kotlin Multiplatform project
v
And the code is in the common part or in the jvm part?
g
in common part
v
common could also run on iOS, so using java classes is hardly possible I guess
👍 1
☝️ 1
g
ahh.yes, i see. It rather platform specific implementation using expect-actual pattern. But I'm wondering if there is any doc that describes such limitation like using java's inputstream from common part in KMP?
just checked, in jvm part InputStream is accessible
v
I have no idea, I don't do KMM or KMP development, just pure JS or pure JVM. But actually it is common sense that you cannot use platform-specific classes in platform independent code without the expect-actual pattern. 😄
g
yup, that's right. Thanks :)
t
Well, how much doc do you need? The common part of a KMP can't have any platform-specific dependencies. If it has no JVM dependencies, you can't use any Java classes
so basically what @Vampire said. Sorry, didn't read the whole comment before sending mine
v
dw
g
sure, that's platform specific class, expect-actual pattern should be used for that