What is a language construct? (was Re: Comment on state of Project Jigsaw)
Alex Buckley
alex.buckley at oracle.com
Thu Jan 5 12:22:42 PST 2012
On 1/5/2012 8:25 AM, Eric Johnson wrote:
> If I were drawing a picture, I'd have a circle with three pie slices:
>
> * tools that need to change merely to accept the new version of the
> class file format
> * tools that don't care about the module information but will need to
> change to work around/ignore said data
> * tools that actually care about the new module information.
>
> Question is, how big are you making that middle slice? If you put the
> module information into an alternate format, I *know* that the second
> slice is an empty set.
(In what follows, I assume 52.0 is the ClassFile version for Java SE 8.)
The various ClassFile attributes proposed by Jigsaw (Module,
ModuleRequires, etc) should have no impact on tools which only know
about pre-52.0 ClassFiles. The JVM Spec has always been very clear that
new attributes can be defined and must be silently ignored by parts of
the system which pre-date them. We already have two new
annotation-related attributes proposed for 52.0 by JSR 308.
The worst-case scenario is a pre-52.0 tool ignoring ClassFile version
and attempting to interpret a 52.0 ClassFile as if it was an earlier
version. This tool is broken (consider an 'invokedynamic' instruction in
a 51.0 ClassFile that's interpreted as 50.0) ... but still, new module
attributes will just be ignored. What _could_ be a problem is any
redefinition of non-attribute artifacts in a 52.0 ClassFile v. 51.0.
Is there any such redefinition? I tried to avoid it, but there are two.
They take effect only when the new ACC_MODULE flag is set. (I regard a
new flag much like a new attribute; it must be safe to add constructs
which in and of themselves don't overlap with existing constructs.) They
are:
1) Non-setting of ACC_INTERFACE no longer means "this is a class".
(Though this is moot because interpreting the ClassFile as a class
anyway will reveal a well-formed but very boring class.)
2) Setting of super_class to 0 no longer means "my supertype is an Object".
So that's the effect of using the ClassFile structure to reify module
information. Tools which properly recognize 52.0 ClassFiles but that
don't care about module information will have to work around (2). Since
such a tool would already be switching on the presence of ACC_MODULE,
(2) is almost trivial.
Alex
More information about the jigsaw-dev
mailing list