不可变的没有类是由eclipse生成的

w3nuxt5m  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(381)

我一直在尝试设置不可变库,但是尽管遵循了指南,eclipse似乎没有在target/generated sources/annotations文件夹中生成任何类
下面是java编译器->注解处理设置的屏幕截图

在工厂路径中,显示不可变值-2.8.2.jar是根据不可变指南选择的--https://immutables.github.io/immutable.html.

我运行了project->clean,然后是project->buildall
我在错误日志中得到一个错误:exception抛出java注解处理器org.immutables.processor。proxyprocessor@63924c86
以及相应的堆栈跟踪

java.lang.Exception: java.lang.UnsupportedClassVersionError: org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:172)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:124)
at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:171)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:138)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotationsInternal(Compiler.java:958)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:932)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:450)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:386)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:371)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:318)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.incrementalBuildLoop(IncrementalImageBuilder.java:190)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:147)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:292)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:212)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:832)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.UnsupportedClassVersionError: org/eclipse/jdt/internal/compiler/apt/model/ModuleElementImpl
    at org.eclipse.jdt.internal.compiler.apt.model.PackageElementImpl.getEnclosingElement(PackageElementImpl.java:120)
    at org.immutables.value.internal.$processor$.meta.$ImportRewriteDisabler.shouldDisableFor($ImportRewriteDisabler.java:81)
    at org.immutables.value.internal.$processor$.meta.$ImportRewriteDisabler.shouldDisableFor($ImportRewriteDisabler.java:41)
    at org.immutables.value.internal.$processor$.meta.$ValueType.sourceHeader($ValueType.java:112)
    at org.immutables.value.internal.$processor$.$Generator_Immutables._t2__packageWhenTopLevel($Generator_Immutables.java:160)
    at org.immutables.value.internal.$processor$.$Generator_Immutables$FragmentDispatch.run($Generator_Immutables.java:19964)
    at org.immutables.value.internal.$generator$.$Templates$Fragment.invoke($Templates.java:248)
    at org.immutables.value.internal.$generator$.$Intrinsics.$($Intrinsics.java:96)
    at org.immutables.value.internal.$processor$.$Generator_Immutables._t4__generateImmutable($Generator_Immutables.java:320)
    at org.immutables.value.internal.$processor$.$Generator_Immutables$FragmentDispatch.run($Generator_Immutables.java:19966)
    at org.immutables.value.internal.$generator$.$Templates$Fragment.invoke($Templates.java:248)
    at org.immutables.value.internal.$generator$.$Intrinsics.$($Intrinsics.java:96)
    at org.immutables.value.internal.$processor$.$Generator_Immutables$1.run($Generator_Immutables.java:23)
    at org.immutables.value.internal.$generator$.$Templates$Fragment.invoke($Templates.java:248)
    at org.immutables.value.internal.$generator$.$Output$7.invoke($Output.java:177)
    at org.immutables.value.internal.$generator$.$Intrinsics.$($Intrinsics.java:96)
    at org.immutables.value.internal.$processor$.$Generator_Immutables._t0__generate($Generator_Immutables.java:20)
    at org.immutables.value.internal.$processor$.$Generator_Immutables$FragmentDispatch.run($Generator_Immutables.java:19962)
    at org.immutables.value.internal.$generator$.$Templates$Fragment.invoke($Templates.java:248)
    at org.immutables.value.internal.$generator$.$AbstractGenerator.invoke($AbstractGenerator.java:57)
    at org.immutables.value.internal.$processor$.$Processor.process($Processor.java:81)
    at org.immutables.value.internal.$generator$.$AbstractGenerator.process($AbstractGenerator.java:87)
    at org.immutables.processor.ProxyProcessor.process(ProxyProcessor.java:72)
    at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:142)
    ... 26 more

我做错什么了?

tnkciper

tnkciper1#

您的不可变jar太新或太旧(或者您用来运行eclipse的java版本太新或太旧)。
您可以在eclipse中检查java版本:找到“about eclipse”选项(在macs上的eclipse菜单下,在其他操作系统上我认为它在“help”下),然后选择configuration选项卡。检查是否有故障 java.home=.... 其中的条目将指向用于启动eclipse本身的jvm。也就是抛出那些错误,或者,不可变系统附带了一个内部编译器(ecj通常是项目使用的java解析器,因为它是快速的、开源的),在这种情况下,就是抛出错误的那个。从堆栈轨迹很难判断是谁的错。
所以,我会检查您的不可变dep的版本,如果它非常旧,请更新它。然后我会检查运行eclipse的vm,如果它非常旧,请更新它。
实际上,我会抛弃不可变的,只使用lombok,但是,我会:p

相关问题