I just saw this support request. I somehow missed seeing it earlier. You are running an ancient version of DrJava (from 2012!) that I don't think is compatible with Java 8. I also do not what compiler you are using. DrJava searches for all the Java compiler it can find in the usual places on your platform, but I doubt that the 2012 edition will load a Java 8 compiler (which should be located in the tools.jar file in your Java JDK 8 installation. I suspect DrJava is finding an older compiler somewhere (or using an old Eclipse (Java 6?) open source compiler that was bundled with old versions of DrJava). You can get the latest official release of the DrJava jar file (labeled "Beta" but that was over a year ago) at drjava.org, or an even more recent build at www.cs.rice.edu/~javaplt/drjavarice. Both are Java 8 compatible. I am running the drjavarice version (DrJava Version : drjava-20200303-210720) on top of the Amazon Corretto 8 JDK which includes a Java 8 compiler. The open source releases of Java like Amazon Corretto 8 include an open source compier, which is now bundled with DrJava for use in case you are running a Java JRE (no compiler include) release instead of a JDK release.

My coding style matches Java 6 rather than Java 8 so I have never tried switching on a String. Now that I know such an option exists, I doubt I will ever use it. Why? I have no idea how it is implemented; AFAIK it is up to the compiler writer. If the implementation uses linear matching (basically an "if-then-else" ladder), it will very run slowly if you have very many switch cases. The implementation could use a hash-table (for near constant time performance in the absence of pathologies), but the hash table lookup overhead is reasonably large (including computing the hash code of the String switch object, unless you intern() all of your Strings [which performs the hashing when you execute the intern() operation]. According to Oracle Java 8 documentation, "The Java compiler generates generally more efficient bytecode from switch statements that use String objects than from chained if-then-else statements." so if the switch statement appears in code that is not performance critical, you should be OK.