I suspect you could get into trouble with this kind of approach. The simple answer is that the JVM interns all Strings by default. However, your problem is much deeper than that - the name of a class is not unique within a single JVM. If the same class is loaded by two different classloaders then there will be two instances of that class object within the JVM which have the same name but which are not equal to each other. If you want to model the semantics of switching on a class then you need a way of capturing that behaviour.