Add cycle avoidance to classpath computation.

Fixes #1002179.