changd
08/21/2019, 9:26 PM@Throws
The API
interface StormcrowBase {
@get:Throws(Exception::class)
val featureNames: ArrayList<String>
}
Java call site
try {
features = stormcrowBase.getFeatureNames();
} catch (Exception e) {
e.printStackTrace();
}
The error I'm getting is Exception is never thrown in the corresponding block
.
Any ideas?LeoColman
08/21/2019, 10:01 PMget:@Throws
and use @Throws
instead?Shawn
08/21/2019, 11:18 PMchangd
08/21/2019, 11:53 PMval
to fun
and the Java interop is working.. but the Kotlin API is pretty ugly now.
@Throws(Exception::class)
fun getFeatureNames(): ArrayList<String>
Funny enough, the java generated decompiled class for both val
and fun
look identicalLeoColman
08/21/2019, 11:54 PMchangd
08/21/2019, 11:54 PMThrowing RuntimeExceptions is the rule for Java in a long long timei've never heard that
LeoColman
08/21/2019, 11:55 PMi've never heard thatClean code establishes that throwing checked exception is bad, and throwing RuntimeException is better, as you don't need to catch them everywhere, unless required
changd
08/21/2019, 11:56 PMLeoColman
08/21/2019, 11:57 PMchangd
08/21/2019, 11:58 PMLeoColman
08/21/2019, 11:59 PMchangd
08/22/2019, 12:00 AMLeoColman
08/22/2019, 12:02 AM