Submission: switch (...) instanceof feature

Joe Darcy Joe.Darcy at Sun.COM
Mon Mar 30 21:43:22 PDT 2009

Jeroen van Maanen wrote:
> I'd like to coin a switch (...) instanceof statement as a new feature of 
> the Java language. Please accept the attached proposal for review.
> Regards, Jeroen


I largely concur with the feedback on this proposal already sent to the 
list; for examples, questions on fall-though semantics, ordering of type 
checks and subtypting, etc.

I suggesting looking over my strings in switch proposal for other 
potential issues with modifying the switch statement:

However, I general don't favor this vein of modification to the switch 

On a related note, I'm at most lukewarm toward switching on class 
literals.  Class literals are constants of a sort, loadable by the "load 
constant" JVM instruction, and from that standpoint are a reasonable 
value to switch on, just like other kinds of constants.  However, off 
hand I only know of one section of code in the JDK that would benefit 
from this capability so there doesn't seem to be a strong case for 
adding it.


More information about the coin-dev mailing list