[rfc] more benevolent java version check

Jiri Vanek jvanek at redhat.com
Fri Jul 29 08:57:32 UTC 2016


ping please?

J.
On 07/27/2016 08:28 PM, Jiri Vanek wrote:
> Hello!
>
> Please accept attached patch which is making java version check for other vm more bullet proof.
>
> Originally, the java version was strictly expecting the searched item on first line.
> However, when eg $JAVA_TOOL_OPTIONS is used, the output of forked process got messy. EG:
>
> java -version
> Picked up JAVA_TOOL_OPTIONS: -XX:+UseShenandoahGC
> OpenJDK 64-Bit Server VM warning: Compressed Oops not supported with ShenandoahGC
> ....
>
> My patch is making the usage of JAVA_TOOL_OPTIONS possible, as it is searching the output of forked
> process by key.
>
>
> Tahnx!
>
>  J.
>
> benevolent_java_version.patch
>
>
> diff -r 7906b5ebfc75 src/share/classes/com/sun/javatest/regtest/JDK.java
> --- a/src/share/classes/com/sun/javatest/regtest/JDK.java	Thu Apr 16 17:45:57 2015 -0700
> +++ b/src/share/classes/com/sun/javatest/regtest/JDK.java	Wed Jul 27 20:23:30 2016 +0200
> @@ -150,9 +150,15 @@
>                      String out = getOutput(p);
>                      int rc = p.waitFor();
>                      if (rc == 0) {
> -                        String[] v = StringUtils.splitEqual(out.trim());
> -                        if (v.length == 2 && v[0].equals(VERSION_PROPERTY))
> -                            version = v[1];
> +                        String[] outs=out.split("\n");
> +                        for (String line : outs) {
> +                            System.out.println(line);
> +                            String[] v = StringUtils.splitEqual(line.trim());
> +                            if (v.length == 2 && v[0].equals(VERSION_PROPERTY)) {
> +                                version = v[1];
> +                                break;
> +                            }
> +                        }
>                      }
>                  } catch (InterruptedException e) {
>                      // ignore, leave version as default
>



More information about the jtreg-dev mailing list