Commit dd36d6c
committed
[build] Support building with JetBrains OpenJDK 11
Context: https://issuetracker.google.com/issues/150189789
Context: dotnet/android#4562
Context: dotnet/android#4567
Bumps to xamarin/xamarin-android-tools/master@36d7fee5
Changes: dotnet/android-tools@bfb66f3...36d7fee
* dotnet/android-tools@36d7fee: JetBrains OpenJDK 11 detection (dotnet#82)
* dotnet/android-tools@12f52ac: Merge pull request dotnet#80 from jonpryor/jonp-drop-net461
* dotnet/android-tools@c7090d0: [Xamarin.Android.Tools.AndroidSdk] Remove net461
JDK 9 -- released 2017-July-27 -- introduced many new features, but
broke various Android SDK toolchain programs in various inscrutable
ways, so the Android community has been "stuck" on JDK 8 ever since.
…until now? A preview version of `apksigner` in the Build-tools 30rc1
package states that it requires Java 9 in order to run, which means we
must explore what is required to build under JDK > 8.
[JetBrains has an OpenJDK 11.0.4 release for macOS][0], which has a
"weird" directory structure but is otherwise workable, so…
Will It Build™?
$ curl -o jbrsdk-11_0_4-osx-x64-b546.1.tar.gz https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
# Above doesn't *actually* work; use a browser to appease Akamai
$ tar xzf jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
$ export JAVA_HOME=$HOME/Downloads/jbrsdk/Contents/Home
$ make prepare JI_MAX_JDK=12
$ make all
Yes, it builds, but that's *misleading*: it's not actually using
`$JAVA_HOME`!
…/Java.Interop/build-tools/scripts/jdk.targets(5,5): warning : Not a valid JDK directory: `…/Java.Interop/jbrsdk/Contents/Home`; via locator: $JAVA_HOME
System.ArgumentException: Could not find required file `jvm` within `…/Java.Interop/jbrsdk/Contents/Home`; is this a valid JDK?
Parameter name: homePath
at Xamarin.Android.Tools.JdkInfo.ValidateFile (System.String name, System.String path)
at Xamarin.Android.Tools.JdkInfo..ctor (System.String homePath)
This is fixed via dotnet/android-tools@36d7fee. Bump
xamarin-android-tools, and `make prepare` still works.
`make all` fails:
$ make all
…
"…/Java.Interop/jbrsdk/Contents/Home/bin/javac" -parameters -source 1.6 -target 1.6 -bootclasspath "…/Java.Interop/jbrsdk/Contents/Home/bin/../jre/lib/rt.jar" -g -d "obj/Debug/classes" java/android/annotation/NonNull.java java/android/annotation/NonNull.java java/com/xamarin/IJavaInterface.java java/com/xamarin/IParameterInterface.java java/com/xamarin/JavaAnnotation.java java/com/xamarin/JavaType.java java/com/xamarin/NestedInterface.java java/com/xamarin/NotNullClass.java java/com/xamarin/ParameterAbstractClass.java java/com/xamarin/ParameterClass.java java/com/xamarin/ParameterClass2.java java/java/util/Collection.java java/NonGenericGlobalType.java
EXEC : warning : [options] source value 6 is obsolete and will be removed in a future release
EXEC : warning : [options] target value 1.6 is obsolete and will be removed in a future release
EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later.
EXEC : warning : [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
EXEC : Fatal error : Unable to find package java.lang in classpath or bootclasspath
The problem is that JetBrains' OpenJDK 11 no longer contains a
`…/jre/lib/rt.jar` file, so the `-bootclasspath` value is now wrong.
Additionally, if you don't use `javac -target`, which implicitly
targets JDK 11, `javac` doesn't like that:
EXEC : error : option --boot-class-path not allowed with target 11
The solution? Don't Do That™; if `javac` from OpenJDK 11 doesn't want
`-bootclasspath`, don't provide it.
Update the `<JdkInfo/>` task to check for the existence of the
`…/jre/lib/rt.jar` file; if it exists, set `$(JreRtJarPath)`,
otherwise the `$(JreRtJarPath)` MSBuild property is empty.
Then update `$(_JavacSourceOptions)` so that it *doesn't* provide
`-bootclasspath` when `$(JreRtJarPath)` is empty.
These three changes -- xamarin-android-tools bump, `<JdkInfo/>`
update, and `$(_JavacSourceOptions)` update -- allow `make all` to
build successfully.
Then we hit *unit* tests. The above `javac` invocation has a warning:
EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later.
Even though we've been using `javac -target 1.6 -parameters` for
*ages*, this combination is no longer supported. In order to use
`javac -parameters` now, we need to use `javac -target 1.8`.
Update `$(JavacSourceVersion)` to 1.8 so that we can continue using
`javac -parameters`, which in turn requires that we update
`tests/Xamarin.Android.Tools.Bytecode-Tests` so that we expect the
newly updated `.class` file MajorVersion values.
[0]: https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz1 parent 6d7266d commit dd36d6c
File tree
13 files changed
+36
-24
lines changed- build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks
- external
- tests/Xamarin.Android.Tools.Bytecode-Tests
13 files changed
+36
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
Lines changed: 21 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
| |||
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
| 110 | + | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
114 | 125 | | |
115 | 126 | | |
116 | 127 | | |
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
| 131 | + | |
120 | 132 | | |
121 | 133 | | |
122 | 134 | | |
| |||
Submodule xamarin-android-tools updated from bfb66f3 to 36d7fee
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments