Skip to content

Commit c9f873a

Browse files
committed
[GR-11085] Add support for overlays for projects using JDK8 (or earlier) internal API.
PullRequest: mx/722
2 parents 4dc0e08 + 08e00aa commit c9f873a

File tree

5 files changed

+230
-117
lines changed

5 files changed

+230
-117
lines changed

README.md

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,42 +116,17 @@ public @interface AddExports {
116116

117117
### Versioning sources for different JDK releases
118118

119-
Mx includes support for multiple versions of a Java source file that is heavily inspired
120-
by [multi-release jars](https://docs.oracle.com/javase/10/docs/specs/jar/jar.html#multi-release-jar-files).
121-
A versioned Java source has a base copy and one or more versioned copies. The signature of each
119+
Mx includes support for multiple versions of a Java class. The mechanism is inspired by and
120+
similar to [multi-release jars](https://docs.oracle.com/javase/10/docs/specs/jar/jar.html#multi-release-jar-files).
121+
A versioned Java class has a base version and one or more versioned copies. The public signature of each
122122
copy (i.e., methods and fields accessed from outside the source file) must be identical.
123-
A versioned copy must be in a project whose Java compliance is greater than the project
124-
containing the base copy. For example, the base copy of [GraalServices.java](https://github.com/oracle/graal/blob/1bc9e1c762c85303d1388f98149bb9bb402f0cff/compiler/src/org.graalvm.compiler.serviceprovider/src/org/graalvm/compiler/serviceprovider/GraalServices.java)
125-
is in a [project with Java compliance of 8](https://github.com/oracle/graal/blob/1bc9e1c762c85303d1388f98149bb9bb402f0cff/compiler/mx.compiler/suite.py#L134).
126-
There is a [GraalServices.java](https://github.com/oracle/graal/blob/1bc9e1c762c85303d1388f98149bb9bb402f0cff/compiler/src/org.graalvm.compiler.serviceprovider.jdk9/src/org/graalvm/compiler/serviceprovider/GraalServices.java)
127-
source file that _presides over_ the base copy when running on JDK 9 or later.
128-
The project containing the latter [uses](https://github.com/oracle/graal/blob/1bc9e1c762c85303d1388f98149bb9bb402f0cff/compiler/mx.compiler/suite.py#L144-L145)
129-
the `multiReleaseJarVersion` attribute to denote that it contains classes to be packaged in
130-
a versioned jar directory. It also specifies the earliest Java version for which it is valid.
131-
132-
When these projects are combined into the same mx distribution, mx will put these class files into the distribution
133-
jar according to the multi-release jar format:
134-
```
135-
> jar tvf mxbuild/dists/graal.jar | grep GraalServices
136-
1562 Tue May 22 22:19:02 CEST 2018 org/graalvm/compiler/serviceprovider/GraalServices$JMXService.class
137-
6546 Tue May 22 22:19:02 CEST 2018 org/graalvm/compiler/serviceprovider/GraalServices.class
138-
1146 Tue May 22 22:19:02 CEST 2018 META-INF/versions/9/org/graalvm/compiler/serviceprovider/GraalServices$1.class
139-
1435 Tue May 22 22:19:02 CEST 2018 META-INF/versions/9/org/graalvm/compiler/serviceprovider/GraalServices$1$1.class
140-
932 Tue May 22 22:19:02 CEST 2018 META-INF/versions/9/org/graalvm/compiler/serviceprovider/GraalServices$JMXService.class
141-
6933 Tue May 22 22:19:02 CEST 2018 META-INF/versions/9/org/graalvm/compiler/serviceprovider/GraalServices.class
142-
```
143-
Resolving classes to the right version is done by the VM at runtime as explained in the JAR specification.
144123

145-
When a distribution also defines a module (e.g., [GRAAL](https://github.com/oracle/graal/blob/1bc9e1c762c85303d1388f98149bb9bb402f0cff/compiler/mx.compiler/suite.py#L1662)),
146-
the versions are _flattened_ when creating the modular jar. That is, the modular jar contains only the class
147-
files that would be resolved at runtime:
148-
```
149-
> jar tvf mxbuild/modules/jdk.internal.vm.compiler.jar | grep GraalServices
150-
1146 Tue May 22 22:19:12 CEST 2018 org/graalvm/compiler/serviceprovider/GraalServices$1.class
151-
1435 Tue May 22 22:19:12 CEST 2018 org/graalvm/compiler/serviceprovider/GraalServices$1$1.class
152-
932 Tue May 22 22:19:12 CEST 2018 org/graalvm/compiler/serviceprovider/GraalServices$JMXService.class
153-
6933 Tue May 22 22:19:12 CEST 2018 org/graalvm/compiler/serviceprovider/GraalServices.class
154-
```
124+
Versioned classes for JDK 9 or later need to be in a project with a `javaCompliance` greater than
125+
or equal to 9 and a `multiReleaseJarVersion` attribute whose value is also greater or equal to 9.
126+
The versioned project must have the base project as a dependency.
127+
128+
Versioned classes for JDK 8 or earlier need to be in a project with a `javaCompliance` less than or
129+
equal to 8 and an `overlayTarget` attribute denoting the base project.
155130

156131
### URL rewriting
157132

eclipse-settings/org.eclipse.jdt.core.prefs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=
123123
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
124124
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
125125
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
126-
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
126+
# Prevent Eclipse warning about "unnecessary" @SuppressWarning("deprecation") annotations.
127+
# It's only unnecessary when compiling against a JDK that has not yet deprecated the
128+
# element in question. The trade off is that Eclipse will no longer warn about other
129+
# truly unnecessary suppressions.
130+
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore
127131
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
128132
org.eclipse.jdt.core.compiler.processAnnotations=disabled
129133
org.eclipse.jdt.core.compiler.source=${javaCompliance}

0 commit comments

Comments
 (0)