Passing current java runtime and toolchain to a test

40 views
Skip to first unread message

ittai zeidman

unread,
Mar 17, 2019, 2:43:37 AM3/17/19
to bazel-...@googlegroups.com, Liam Miller-Cushon, Lukács T. Berki, Or Shachar, Shachar Anchelovich, Shai Nagar
Hi,
I'm working on bazel-integration-testing library and encountered an issue while trying to get it to support bazel >= 0.21.
This release, IINM, introduces the fetching of the remotejdk if no javabase/host_javabase is given explicitly.
I need my tests to be sandboxed so the bazel in the test can't download the remotejdk by itself.

What I'd like is to find the current java runtime and current java toolchain from my starlark rule, add the runtime as data dependency (probably not needed since happens implicitly) and pass their location/label to the test so that the test-runner can tell the test-bazel to use them.

I've taken a look at ctx.attr._java_runtime[java_common.JavaRuntimeInfo].java_home which returns "external/local_jdk" but:
1. I'm not sure that's what I need.
2. I need to trim the "external" part (java_home_runfiles_path is similar in returning "../local_jdk").
3. Not sure why local_jdk is returned and not the remotejdk. I have no javabase defined in my user folder or the repository's root.
4. When I run "java -version" on the local_jdk in the runfiles I get java8 while the test fails with "Unrecognized VM option 'CompactStrings" which means the jvm is 9 or above.

If anyone has insights about the above I'd really appreciate it,
Ittai

ittai zeidman

unread,
Mar 17, 2019, 3:09:09 AM3/17/19
to bazel-...@googlegroups.com, Liam Miller-Cushon, Lukács T. Berki, Or Shachar, Shachar Anchelovich, Shai Nagar
Re trimming I can do $TEST_SRCDIR/workspace_name/$java_home_runfiles_path which will work.
Still not sure why I get local_jdk

Lukács T. Berki

unread,
Mar 18, 2019, 5:26:57 AM3/18/19
to ittai zeidman, Irina Iancu, bazel-...@googlegroups.com, Liam Miller-Cushon, Or Shachar, Shachar Anchelovich, Shai Nagar
(Irina, can you take a look?)
--
Lukács T. Berki | Software Engineer | lbe...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg, HRB 86891

ittai zeidman

unread,
Mar 24, 2019, 1:26:56 AM3/24/19
to Lukács T. Berki, Irina Iancu, bazel-...@googlegroups.com, Liam Miller-Cushon, Or Shachar, Shachar Anchelovich, Shai Nagar
Irina,
Any thoughts?

Liam Miller-Cushon

unread,
Mar 25, 2019, 6:49:47 PM3/25/19
to ittai zeidman, bazel-...@googlegroups.com, Lukács T. Berki, Or Shachar, Shachar Anchelovich, Shai Nagar
On Sat, Mar 16, 2019 at 11:43 PM ittai zeidman <itt...@gmail.com> wrote:
This release, IINM, introduces the fetching of the remotejdk if no javabase/host_javabase is given explicitly.

--incompatible_use_remotejdk_as_host_javabase only applies to the --host_javabase: https://github.com/bazelbuild/bazel/issues/6656
 
If --javabase is unset it defaults to the locally installed JDK, with the assumption that's the JDK the build is targeting.

4. When I run "java -version" on the local_jdk in the runfiles I get java8 while the test fails with 
"Unrecognized VM option 'CompactStrings" which means the jvm is 9 or above.

I think that's backwards? -XX:+CompactStrings was added in 9 (http://openjdk.java.net/jeps/254); the flag is rejected by earlier releases.

Anyway, JavaRuntimeInfo.java_home (or java_home_runfiles_path if you want a runfiles-relative path) sounds like the right approach.
Reply all
Reply to author
Forward
0 new messages