我如何在 Guava 中使用 ClassPath::getAllClasses?

How do I use ClassPath::getAllClasses in Guava?

如何在 Guava 中使用 ClassPath::getAllClasses?下面的代码是我能做的最简单的例子。但它只是 returns 一个空集合!我使用 Guava 23.0 和 Eclipse 4.7.2。

import com.google.common.reflect.*;
import java.io.*;

class Test {
    public static void main(String[] args) {
        try {
            System.out.println(ClassPath.from(Test.class.getClassLoader()).getAllClasses());
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        }
    }
}

我从 Guava 版本 23.0 更新到 24.0,这解决了这个问题。该集合不再为空。