尝试在我的gradle构建中执行javadoc
任务时,将打印出以下消息(以及我可以应要求提供的堆栈跟踪):
javadoc: error - An internal exception has occurred.
(com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: /home/vtcakavsmoace/IdeaProjects/DiscordSRV2-Core/build/classes/java/main/com/discordsrv/core/auth/PlayerUserAuthenticator$1$1.class
bad enclosing class for com.discordsrv.core.auth.PlayerUserAuthenticator$1$1: com.discordsrv.core.auth.PlayerUserAuthenticator$1
Please remove or make sure it appears in the correct subdirectory of the classpath.)
Please file a bug against the javadoc tool via the Java bug reporting page
(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
for duplicates. Include error messages and the following diagnostic in your report. Thank you.
com.sun.tools.javac.code.ClassFinder$BadClassFile: bad class file: /home/vtcakavsmoace/IdeaProjects/DiscordSRV2-Core/build/classes/java/main/com/discordsrv/core/auth/PlayerUserAuthenticator$1$1.class
bad enclosing class for com.discordsrv.core.auth.PlayerUserAuthenticator$1$1: com.discordsrv.core.auth.PlayerUserAuthenticator$1
Please remove or make sure it appears in the correct subdirectory of the classpath.
javadoc似乎正在尝试记录匿名内部类的匿名内部类。
在build文件夹中进行进一步检查时,您可以看到该匿名类根本不存在:
这是文件中唯一包含匿名类的方法(为清楚起见已简化):
public void doSomething() {
map.forEach((key, value) -> key.doSomething(response -> {
invokeWithCallback(value, var, new FutureCallback<Boolean>() {
@Override
public void onSuccess(final @Nullable Boolean result) {
...
new Pair<Key, Value>() {
...
}
...
}
@Override
public void onFailure(final @Nonnull Throwable t) {
...
}
});
}
}));
}
我应该如何处理以确保javadoc任务可以完成?
编辑:
多做一些探索;删除内部匿名类可以完成javadoc任务,因此这个匿名实例似乎是问题所在。
答案 0 :(得分:2)
解决方法:
声明一个内部类,在其中执行匿名实例化。这样可以防止javadoc尝试解析不存在的类文件。以问题的格式:
public void doSomething() {
map.forEach((key, value) -> key.doSomething(response -> {
invokeWithCallback(value, var, new MyCallback(...));
}
}));
}
private class MyCallback implements FutureCallback<Boolean> {
...
@Override
public void onSuccess(final @Nullable Boolean result) {
...
new Pair<Key, Value>() {
...
}
...
}
...
}
话虽这么说,我很快就会向Java提交更正式的错误报告。