> they may contain characters from the entire Unicode code space.
The Java 8 JVM spec says that class names can contain characters from the
entire Unicode code space "where not further constrained".  The only
explicit restriction that is specified is that an unqualified name cannot
contain '.',  ';', '[' or '/'.

However, historically, the JVM has been much more restrictive.  If you put
a single quote or double quote or asterix in a package or class name then
the 1.4.2 JVM would report a "ClassFormatError: Illegal class name".  Even
the Java 9 JVM will currently report this error if you are executing a
class compiled for Java 1.4.2.  Earlier JVMs  would not even allow fully
numeric package or class names.

> How are class and other names encoded in the "text script file" today?
Given the restrictiveness of previous JVMs, package and class names have
been assumed to be in a format that would be accepted by a Java compiler.
That is no spaces, single quotes, double quotes or asterixes allowed.

In response to your questions, I have performed some tests and see that the
newer JVMs will allow  spaces, single quotes, double quotes and asterixes
in package, class, field and method names provided the class file is in a
newer format. So the nightmare that is being proposed for module names
technically already exists for package, class, field and method names in
more recent class file versions.

Given the above, could I respectfully broaden my initial question to ask
whether the relatively recent decision to allow spaces, single quotes,
double quotes and asterixes in package, class, field and method names could
be reconsidered?  I would suggest that it is most unlikely that anyone
would need to use such characters in that context.  The alternative of
dealing with such characters in the scenario of scripting languages as I
have described would be quite ugly.

Reply via email to