Scala - Java interop: can Scala emit enums in bytecode for Java to consume?
Question
I have a project that is mixed Java/Scala, it is Java GUI code that makes use of a Scala library. Is there a way to write Scala code such that it will emit Java enums on compile time? The approaches I tried so far (sealed case classes, extend Enumeration) seem to generate normal classes which makes working with them from Java much hairier than straight up enums.
Solution
Why can't you write your enum
class in Java? Mixed-source (i.e. Java + Scala) projects are perfectly feasible...
OTHER TIPS
Scala only supports Java 1.4 features at this point.
Java Enums were introduced in Java 1.5.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow