Proposal: Move the `Module` and `Layer` classes from `java.lang.reflect` to `java.lang`

mark.reinhold at oracle.com mark.reinhold at oracle.com
Wed Mar 29 20:56:40 UTC 2017


2017/3/27 23:15:59 -0700, Remi Forax <forax at univ-mlv.fr>:
> One problem I see is that Module is an annotated elements and usually
> those belong to java.lang.reflect.  So the idea that Module can be
> moved to java.lang with no dependency on java.lang.reflect is flawed
> because of that.

I didn't claim that `java.lang.Module` wouldn't depend upon anything in
`java.lang.reflect`.

Other types in the `java.lang` package already do this.  `Class` and
`Package` implement `AnnotatedElement`, and `Class` further implements
both `GenericDeclaration` and `Type` (and `java.io.Serializable`, ugh).
There are also, of course, many uses of non-`java.lang` types in the
signatures of methods and fields in types in that package.

The `java.lang` package has never been able to stand on its own, as
aesthetically pleasing as that might have been -- not even in JDK 1.0.

> I still think it's a good move, modules are now first class citizens
> so Module belongs to java.lang.
> 
> The ties between java.lang and java.lang.reflect are strong and I do
> not see how to untangle them in the future, but that's a discussion we
> can have in the future when we will want to introduce generics over
> primitives/class values.

Agreed.

- Mark


More information about the jpms-spec-experts mailing list