Are sealed classes enforced in Java and, if yes, how?

It is possible to define sealed classes in Scala, which are basically final except if the sub-classing happens in the same file.

It seems that the JVM doesn't allow final class bytecode and subclasses of it.

Considering that there is no "notion" of source file in the bytecode, how is this restriction enforced?

Therefore, how can javac prevent a Scala sealed class from being sub-classed in Java?

12
задан soc 16 December 2010 в 12:26
поделиться