-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] Support building with JetBrains OpenJDK 11 (#629)
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 (#82) * dotnet/android-tools@12f52ac: Merge pull request #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=`pwd`/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.gz
- Loading branch information
Showing
13 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule xamarin-android-tools
updated
from bfb66f to 36d7fe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters