Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Exception using Closeable interface with Socket

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.

like image 835
csname1910 Avatar asked Jan 25 '14 17:01

csname1910


1 Answers

To quote Android issue tracker:

Socket implements Closeable only since API level 19 (kitkat) but that information isn't in the generated documentation.

like image 93
Nigel Tufnel Avatar answered Oct 29 '22 05:10

Nigel Tufnel