Q: what exception would be appropriate to throw when an android permission is missing? Would like to enforce use of permissions and "fail fast" - some older APIs fail silently IIRC - so I came up with :
private static void assertPermission(Context ctx, String perm) {
    final int checkPermission = ctx.getPackageManager().checkPermission(
        perm, ctx.getPackageName());
    if (checkPermission != PackageManager.PERMISSION_GRANTED) {
        throw new IllegalStateException("Permission " + perm
            + " is required");
    }
}

I would like to use a permission appropriate to the abstraction - and follow effective Java's advice : Favor the use of standard exceptions.


*

*Should I use IllegalStateException or is there some more appropriate
exception ? 

*Should I use a checked exception ?


A: If you want a generic Java exception, I'd use a UnsupportedOperationException, which is a RuntimeException used when an unsupported operation is attempted. 
According to the doc, the IllegalStateException is more linked to the VM itself : 

Thrown when an action is attempted at a time when the VM is not in the
  correct state.


A: Based on @Selvin's comment I let android throw the exception - I got :

09-20 17:13:39.115: E/AndroidRuntime(1688): java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10064 nor current process has android.permission.READ_PHONE_STATE.

So it indeed appears that android uses java.lang.SecurityException - and to be consistent with android I'll have to use this
