Why does javac collect transitive dependencies?

73 views
Skip to first unread message

asuf...@gmail.com

unread,
Sep 6, 2018, 12:46:33 PM9/6/18
to bazel-discuss
I notice https://blog.bazel.build/2017/06/28/sjd-unused_deps.html saying "Bazel always passes the entire transitive classpath to javac, not only the direct classpath."

It's not immediately obvious to me what problem is being solved by doing this. Can anybody explain why it works that way?

Greg Estren

unread,
Sep 11, 2018, 1:44:06 PM9/11/18
to asuf...@gmail.com, bazel-discuss
Hi Andrew,

I think the idea is that, in order to properly compile Foo.java, the compiler needs not just the symbols Foo references, but also the symbols those symbols reference.

For example:

class Foo {
  List<String> items = DirectDep.items();
}

class DirectDep {
  static ImmutableList<String> items() {}
}

Foo's direct classpath doesn't need ImmutableList because Foo never references ImmutableList. But ImmutableList still has to be available to Foo's compilation to determine if List<String> is a valid type assignment.

This may also apply to patterns like:

class Foo {
  DirectDep.someCall().someOtherCall().yetSomeOtherCall();
}

where it's necessary to know the class types the various calls return to determine if the above sequence is valid.




On Thu, Sep 6, 2018 at 12:46 PM <asuf...@gmail.com> wrote:
I notice https://blog.bazel.build/2017/06/28/sjd-unused_deps.html saying "Bazel always passes the entire transitive classpath to javac, not only the direct classpath."

It's not immediately obvious to me what problem is being solved by doing this. Can anybody explain why it works that way?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/e1530591-b33a-4c89-9782-8cd73eb4e76c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages