Specify platform types

For some un-annotated java class:

class Foo {
    String foo() { /* ... */ }
}

Is there any way to specify the platform type for nullability/mutability? like a python stub file.

Maybe introduce a soft keyword stub class:

stub class Foo {
    fun foo(): String?
}

stub class javax.servlet {
    /* ... */
}

If you are using IntelliJ, you can define external annotations for java classes that you cannot modify.

how?