@@ -19,6 +19,7 @@ namespace GooglePlayServices {
19
19
using System . Collections . Generic ;
20
20
using System . Globalization ;
21
21
using System . IO ;
22
+ using System . Text . RegularExpressions ;
22
23
using UnityEditor ;
23
24
24
25
using Google ;
@@ -185,19 +186,12 @@ internal static void CheckJdkForApiLevel() {
185
186
float majorMinorVersion = 0 ;
186
187
// The version string is can be reported via stderr or stdout so scrape the
187
188
// concatenated message string.
188
- foreach ( var line in CommandLine . SplitLines ( result . message ) ) {
189
- if ( line . StartsWith ( "java version " ) ) {
190
- var tokens = line . Split ( ) ;
191
- var versionString = tokens [ tokens . Length - 1 ] . Trim ( new [ ] { '"' } ) ;
192
- var components = versionString . Split ( new [ ] { '.' } ) ;
193
- if ( components . Length < 2 ) {
194
- continue ;
195
- }
196
- if ( ! float . TryParse ( components [ 0 ] + "." + components [ 1 ] , NumberStyles . Any ,
197
- CultureInfo . InvariantCulture , out majorMinorVersion ) ) {
198
- continue ;
199
- }
200
- }
189
+ string pattern = "^(?<model>java||openjdk) version \" (?<major>\\ d).(?<minor>\\ d).(?<patch>\\ d).*$" ;
190
+
191
+ Match match = Regex . Match ( result . message , pattern , RegexOptions . Multiline ) ;
192
+ if ( match . Success ) {
193
+ float . TryParse ( match . Groups [ "major" ] . Value + "." + match . Groups [ "minor" ] . Value , NumberStyles . Any ,
194
+ CultureInfo . InvariantCulture , out majorMinorVersion ) ;
201
195
}
202
196
if ( majorMinorVersion == 0 ) {
203
197
LogJdkVersionFailedWarning ( javaPath , result . message ) ;
0 commit comments