-
Notifications
You must be signed in to change notification settings - Fork 31
Better support no installed JDKs on macOS #48
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
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
| { | ||
| if (logger == null) | ||
| throw new ArgumentNullException (nameof (logger)); | ||
| logger = logger ?? DefaultConsoleLogger; |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there also be an overload where you don’t have to pass a null logger?
What happens if there is no JDK installed on macOS? $ mv ~/Library/Developer/Xamarin/jdk ~/Library/Developer/Xamarin/jdk.bk $ sudo mv /Library/Java/JavaVirtualMachines /Library/Java/JavaVirtualMachines.bk `JdkInfo` doesn't like this, which is to be expected, but *how* it doesn't like it is...bad: $ csharp -r:bin/Debug/Xamarin.Android.Tools.AndroidSdk.dll csharp> Xamarin.Android.Tools.JdkInfo.GetKnownSystemJdkInfos(); Error getting SDK info: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) at System.Xml.XmlTextReaderImpl.Throw (System.String res) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () at System.Xml.XmlTextReaderImpl.ParseDocumentContent () at System.Xml.XmlTextReaderImpl.Read () at System.Xml.XmlReader.MoveToContent () at System.Xml.Linq.XElement.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) at System.Xml.Linq.XElement.Parse (System.String text, System.Xml.Linq.LoadOptions options) at System.Xml.Linq.XElement.Parse (System.String text) at Xamarin.Android.Tools.JdkInfo+<GetLibexecJdkPaths>d__54.MoveNext () ... Er, what? The problem is the output of `/usr/libexec/java_home -X`: $ /usr/libexec/java_home -X Unable to find any JVMs matching version "(null)". <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array/> </plist> No Java runtime present, try --request to install. What's happening is that `java_home` is writing XML to stdout, and an error message to stderr. `ProcessUtils.Exec()`, meanwhile, was *merging **both*** `stdout` and `stderr` into *one* stream, and the result was *not* valid XML, hence the `XmlException`. The fix? Allow `stderr` to be separate from `stdout`, so that `JdkInfo.GetLibexecJdkPaths()` can get valid XML. Additionally, because I'm finding it increasingly annoying needing to provide the `logger` parameter to `AndroidSdkInfo`/etc., update the `AndroidSdkInfo` constructor so that `logger` is *optional*. If it isn't provided, we'll write our log messages to `System.Console`.
7ccd047 to
77f2683
Compare
jonathanpeppers
approved these changes
Aug 14, 2018
jonpryor
added a commit
that referenced
this pull request
Aug 15, 2018
What happens if there is no JDK installed on macOS? $ mv ~/Library/Developer/Xamarin/jdk ~/Library/Developer/Xamarin/jdk.bk $ sudo mv /Library/Java/JavaVirtualMachines /Library/Java/JavaVirtualMachines.bk `JdkInfo` doesn't like this, which is to be expected, but *how* it doesn't like it is...bad: $ csharp -r:bin/Debug/Xamarin.Android.Tools.AndroidSdk.dll csharp> Xamarin.Android.Tools.JdkInfo.GetKnownSystemJdkInfos(); Error getting SDK info: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) at System.Xml.XmlTextReaderImpl.Throw (System.String res) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () at System.Xml.XmlTextReaderImpl.ParseDocumentContent () at System.Xml.XmlTextReaderImpl.Read () at System.Xml.XmlReader.MoveToContent () at System.Xml.Linq.XElement.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) at System.Xml.Linq.XElement.Parse (System.String text, System.Xml.Linq.LoadOptions options) at System.Xml.Linq.XElement.Parse (System.String text) at Xamarin.Android.Tools.JdkInfo+<GetLibexecJdkPaths>d__54.MoveNext () ... Er, what? The problem is the output of `/usr/libexec/java_home -X`: $ /usr/libexec/java_home -X Unable to find any JVMs matching version "(null)". <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array/> </plist> No Java runtime present, try --request to install. What's happening is that `java_home` is writing XML to stdout, and an error message to stderr. `ProcessUtils.Exec()`, meanwhile, was *merging **both*** `stdout` and `stderr` into *one* stream, and the result was *not* valid XML, hence the `XmlException`. The fix? Allow `stderr` to be separate from `stdout`, so that `JdkInfo.GetLibexecJdkPaths()` can get valid XML. Additionally, because I'm finding it increasingly annoying needing to provide the `logger` parameter to `AndroidSdkInfo`/etc., update the `AndroidSdkInfo` constructor so that `logger` is *optional*. If it isn't provided, we'll write our log messages to `System.Console`.
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this pull request
Aug 16, 2018
Context; dotnet/android-tools@917d3b3...9e78d6e Fixes for OpenJDK: dotnet/android-tools#43 dotnet/android-tools#45 Better logging: dotnet/android-tools#46 Fix for missing JDKs on MacOS: dotnet/android-tools#48 Tests now pass on Windows: dotnet/android-tools#47
grendello
pushed a commit
to dotnet/android
that referenced
this pull request
Aug 17, 2018
Context; dotnet/android-tools@917d3b3...9e78d6e Fixes for OpenJDK: dotnet/android-tools#43 dotnet/android-tools#45 Better logging: dotnet/android-tools#46 Fix for missing JDKs on MacOS: dotnet/android-tools#48 Tests now pass on Windows: dotnet/android-tools#47
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What happens if there is no JDK installed on macOS?
JdkInfodoesn't like this, which is to be expected, but how itdoesn't like it is...bad:
Er, what?
The problem is the output of
/usr/libexec/java_home -X:What's happening is that
java_homeis writing XML to stdout, and anerror message to stderr.
ProcessUtils.Exec(), meanwhile, wasmerging both
stdoutandstderrinto one stream, and theresult was not valid XML, hence the
XmlException.The fix? Allow
stderrto be separate fromstdout, so thatJdkInfo.GetLibexecJdkPaths()can get valid XML.Additionally, because I'm finding it increasingly annoying needing to
provide the
loggerparameter toAndroidSdkInfo/etc., update theAndroidSdkInfoconstructor so thatloggeris optional. If itisn't provided, we'll write our log messages to
System.Console.