我在AppEngine连接的Android项目中成功使用了RequestFactory好几个月.但有时候,我在我的子类RequestFactory的文件中遇到了问题
public interface MyRequestFactory extends RequestFactory {
...
}
Eclipse在“public interface …”行上给了我一个红色X,我得到的错误如下所示. (注意这不是运行时,它只是在我正在编辑的Eclipse窗口中)
奇怪的是,我通常可以做几个Project->清理和编辑代码几次,从不进行任何实际的代码更改,然后“保存”,问题总是消失.这次它被卡住了.
有任何想法吗?
java.lang.NullPointerException at
org.eclipse.jdt.apt.core.internal.AptCompilationParticipant.addJava6GeneratedFile(AptCompilationParticipant.java:272)
at
org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl.addNewUnit(IdeProcessingEnvImpl.java:132)
at
org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeJavaSourceOutputStream.close(IdeJavaSourceOutputStream.java:72)
at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:319) at
sun.nio.cs.StreamEncoder.close(StreamEncoder.java:148) at
java.io.OutputStreamWriter.close(OutputStreamWriter.java:233) at
java.io.BufferedWriter.close(BufferedWriter.java:265) at
java.io.PrintWriter.close(PrintWriter.java:312) at
com.google.web.bindery.requestfactory.apt.DeobfuscatorBuilder.visitType(DeobfuscatorBuilder.java:146)
at
com.google.web.bindery.requestfactory.apt.DeobfuscatorBuilder.visitType(DeobfuscatorBuilder.java:43)
at
org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl.accept(TypeElementImpl.java:60)
at
javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:139)
at
com.google.web.bindery.requestfactory.apt.ScannerBase.scan(ScannerBase.java:63)
at
com.google.web.bindery.requestfactory.apt.State.executeJobs(State.java:248)
at
com.google.web.bindery.requestfactory.apt.RfValidator.process(RfValidator.java:83)
at
org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
at
org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
at
org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManag
er.java:159) at
org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorMan
ager.java:134) at
org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:813)
at
org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:432)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:329)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:134)
at
org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265)
at
org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
at org.eclipse.core.internal.events.BuildManager
$2.run(BuildManager.java:728) at
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager
$1.run(BuildManager.java:292) at
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
解决方法:
这是一个已知的Eclipse bug.我发现的唯一解决方案是重启eclipse.有时我必须在没有注释的情况下编译然后重新启动.