In an Android app, I added this code to onCreate()
Closeable sss = new Socket();
if (!(sss instanceof Closeable)) {
throw new Runtim
For future readers, I want to clarify something that was assumed to be evident by everyone in this discussion:
How could I assign Closeable sss = new Socket(); if Socket is not Closeable?
The API requirements specified in AndroidManifest.xml are:
and the device reports
android.os.Build.VERSION.SDK_INT=16
The code was compiled for API level 19, this is why it was successfully compiled. But it was run on API level 16, and this is why it failed.
In other words, the compile-time check was performed for API19 on one computer (the desktop PC) while the run-time check was performed for API16 on another computer (the handheld device).