-
Notifications
You must be signed in to change notification settings - Fork 58
[build] Support building with JetBrains OpenJDK 11 #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or 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
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.gz
grendello
approved these changes
Apr 16, 2020
jonpryor
added a commit
that referenced
this pull request
Apr 22, 2020
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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 30rc1package 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, which has a
"weird" directory structure but is otherwise workable, so…
Will It Build™?
Yes, it builds, but that's misleading: it's not actually using
$JAVA_HOME
!This is fixed via dotnet/android-tools@36d7fee. Bump
xamarin-android-tools, and
make prepare
still works.make all
fails: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 implicitlytargets JDK 11,
javac
doesn't like that: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 -- allowmake all
tobuild successfully.
Then we hit unit tests. The above
javac
invocation has a warning:Even though we've been using
javac -target 1.6 -parameters
forages, this combination is no longer supported. In order to use
javac -parameters
now, we need to usejavac -target 1.8
.Update
$(JavacSourceVersion)
to 1.8 so that we can continue usingjavac -parameters
, which in turn requires that we updatetests/Xamarin.Android.Tools.Bytecode-Tests
so that we expect thenewly updated
.class
file MajorVersion values.