Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Commit 36d7fee

Browse files
authored
JetBrains OpenJDK 11 detection (#82)
Context: https://bintray.com/jetbrains/intellij-jdk/openjdk11-osx-x64 OpenJDK 11 from JetBrains does not have the `jre` directory which, so far, has been required by the `JdkInfo` class. Instead, there's just the `lib` directory which should be searched for the JVM libraries instead of `jre`. Modify `JdkInfo` so that it first checks the `jre` directory and, failing to find it, looks for the `lib` directory in the OpenJDK installation root. These changes allow Xamarin.Android.Tools tp detect JetBrains OpenJDK 11 properly.
1 parent 12f52ac commit 36d7fee

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
namespaceXamarin.Android.Tools
1414
{
1515
publicclassJdkInfo{
16+
staticreadonlystring[]JdkLibraryTopDirs={
17+
"jre",
18+
"lib",
19+
};
1620

1721
publicstringHomePath{get;}
1822

@@ -52,9 +56,23 @@ public JdkInfo (string homePath)
5256
JarPath=ProcessUtils.FindExecutablesInDirectory(binPath,"jar").FirstOrDefault();
5357
JavaPath=ProcessUtils.FindExecutablesInDirectory(binPath,"java").FirstOrDefault();
5458
JavacPath=ProcessUtils.FindExecutablesInDirectory(binPath,"javac").FirstOrDefault();
59+
60+
stringtopDir=null;
61+
foreach(stringdirinJdkLibraryTopDirs){
62+
topDir=Path.Combine(HomePath,dir);
63+
if(!Directory.Exists(topDir)){
64+
topDir=null;
65+
continue;
66+
}
67+
break;
68+
}
69+
70+
if(String.IsNullOrEmpty(topDir))
71+
topDir=Path.Combine(HomePath,JdkLibraryTopDirs[0]);
72+
5573
JdkJvmPath=OS.IsMac
56-
?FindLibrariesInDirectory(Path.Combine(HomePath,"jre"),"jli").FirstOrDefault()
57-
:FindLibrariesInDirectory(Path.Combine(HomePath,"jre"),"jvm").FirstOrDefault();
74+
?FindLibrariesInDirectory(topDir,"jli").FirstOrDefault()
75+
:FindLibrariesInDirectory(topDir,"jvm").FirstOrDefault();
5876

5977
ValidateFile("jar",JarPath);
6078
ValidateFile("java",JavaPath);

0 commit comments

Comments
 (0)