Porting @optional selectors in protocols to Java interfaces
===

So, let's say you have this:

    if ([foo respondsToSelector:@selector(bar:)]) {
       [foo bar:abc];
    } else {
       [qux mux:abc];
    }

And both `bar:` and `mux:` have side effects.

How would you port that to Java, where there is no such things as @optional members in an protocol (interface)?

I can think of three ways:

 1. The C way: add a method to the interface that returns a bitfield representing which methods are implemented and valid.
 2. The COM way: modify the interface so that all methods return a result code and check for E_NOTIMPL.  Use out params for return values.
 3. The (what I imagine is the) Java way: mark each interface method as throwing UnsupportedOperationException and catch them to check for unimplemented methods.

Did I miss any other compelling choices?  Assuming this code is not frequently called so we don't need to optimize for performance, I'm thinking 3 is the best way as it is enforcable.  Are there arguments for the alternatives?