When I try to close a socket through its Closeable interface, I get an exception:
new java.net.Socket().close();
// no error
((java.io.Closeable) new java.net.Socket()).close();
// Throws: java.lang.IncompatibleClassChangeError: interface not implemented
Why is that? The problem is only on Android devices, not on Java programs running on desktop.
To quote Android issue tracker:
Socket implements Closeable only since API level 19 (kitkat) but that information isn't in the generated documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With