Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 17 compatibility #3976

Closed
keturn opened this issue May 22, 2020 · 16 comments · Fixed by #5162
Closed

Java 17 compatibility #3976

keturn opened this issue May 22, 2020 · 16 comments · Fixed by #5162
Labels
Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. Size: L Very big effort likely requiring a lot of research and work in many areas across the codebase Status: Needs Investigation Requires to be debugged or checked for feasibility, etc.

Comments

@keturn
Copy link
Member

keturn commented May 22, 2020

Edit: For those troubleshooting Java issues see also this page

Java 17 is the latest Long-Term Service release. Distributions are available from Adoptium as of September 22, 2021.

It is the first LTS release to have jpackage, the low-latency garbage collectors ZGC and Shenandoah, and maybe if we're lucky, the new foreign memory access API. Just to name a few things of potential interest to game development in addition to the other language niceties.

I thought it'd be good to have a tracking issue as a place to attract notes about problems that come up when people try using java 14, java 15, java 16, or java 17.

What you were trying to do

play (or develop) Terasology on the latest release of the JDK version ▁▁

What actually happened

As soon as I ▁(verb)▁ the ▁(noun)▁, Gooey Jr turned in to an ▁(animal)▁ and said: ▁▁▁▁▁▁▁▁

How to reproduce

  • Step 1
  • Step 2
  • Step 3

Log details and game version

Computer details

@keturn keturn added Status: Needs Investigation Requires to be debugged or checked for feasibility, etc. Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. Needs Info Size: L Very big effort likely requiring a lot of research and work in many areas across the codebase labels May 22, 2020
@DarkWeird
Copy link
Contributor

Yeah!
We many discussed about java projects on discord:
Panama(foreign memory access api)
ZDC(for using we can not compile, but run)

Jpackage - it is required modular java.
Seems, we cannot use it. We will cannot share jdk with launcher

@GIANTCRAB
Copy link

I'm not sure if I should create an issue or write a comment here. Let me know if you need more details.

What you were trying to do

I was trying to run Gradle Wrapper jar game with a complete blank installation (no modules).

What actually happened

It failed, throwing an error. This is related to the change in Java API Method FileSystems.newFileSystem between version 11 and 14.

How to reproduce

  1. .\gradlew jar game
  2. wait for compilation
  3. error will throw up

Log details and game version

TeraEd VERSION: 3.3.0-SNAPSHOT

> Task :engine:compileJava
D:\GameDev\Terasology\engine\src\main\java\org\terasology\persistence\internal\AbstractStorageManager.java:126: error: reference to newFileSystem is ambiguous
            try (FileSystem chunkZip = FileSystems.newFileSystem(chunkPath, null)) {
                                                  ^
  both method newFileSystem(Path,ClassLoader) in FileSystems and method newFileSystem(Path,Map<String,?>) in FileSystems match
D:\GameDev\Terasology\engine\src\main\java\org\terasology\persistence\internal\SaveTransaction.java:430: error: reference to newFileSystem is ambiguous
                    try (FileSystem oldZip = FileSystems.newFileSystem(oldChunkZipPath, null)) {
                                                        ^
  both method newFileSystem(Path,ClassLoader) in FileSystems and method newFileSystem(Path,Map<String,?>) in FileSystems match
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

> Task :engine:compileJava FAILED

FAILURE: Build failed with an exception.

Computer details

  • Windows 10
  • AdoptOpenJDK 14.0.2
  • Branch: dev-develop
  • Commit used f683f12

To fix this issue, I temporarily downgraded to version 11 of OpenJDK.

@skaldarnar
Copy link
Member

Hi @GIANTCRAB and thanks for the report!

Your observation is right, the Java API changed between Java 11 and Java 14. This issue is meant to collect such issues so that we are able to upgrade to Java 14 (or newer) at some point.

To fix this issue, I temporarily downgraded to version 11 of OpenJDK.
Your temporary fix is actually what is required for building from source 😉

@keturn
Copy link
Member Author

keturn commented Jul 25, 2020

I see, Java 13 added new methods, so when we pass null it's ambiguous whether that's a null ClassLoader or a null something-else.

That's easy enough to make forward-compatible.

It's the sort of thing that it seems like we might be able to catch categorically with one of the static analysis tools, but I haven't found anything in IntelliJ or SpotBugs that looks like "show me things that are incompatible with a future JDK," so I guess try-it-and-see will be how we find these.

(I'm also surprised the code in question needs that method, but it wouldn't be the first time Java's file-handling stuff has surprised me.)

@keturn
Copy link
Member Author

keturn commented Sep 7, 2020

I tried and failed to run with the current release candidate for JDK 15.

OpenJDK 64-Bit Server VM warning: You have loaded library ~/IdeaProjects/Terasology/natives/linux/liblwjgl.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
java.lang.UnsatisfiedLinkError: ~/IdeaProjects/Terasology/natives/linux/liblwjgl64.so: ~/.jdks/openjdk-15+36-1562/lib/libjawt.so: version `SUNWprivate_1.1' not found (required by ~/IdeaProjects/Terasology/natives/linux/liblwjgl64.so)
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2407)
	at java.base/java.lang.Runtime.load0(Runtime.java:747)
	at java.base/java.lang.System.load(System.java:1857)
	at org.lwjgl.Sys$1.run(Sys.java:70)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
	at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
	at org.lwjgl.Sys.loadLibrary(Sys.java:87)
	at org.lwjgl.Sys.<clinit>(Sys.java:117)
	at org.terasology.engine.internal.TimeLwjgl.<init>(TimeLwjgl.java:23)
	at org.terasology.engine.subsystem.lwjgl.LwjglTimer.preInitialise(LwjglTimer.java:36)
	at org.terasology.engine.TerasologyEngine.preInitSubsystems(TerasologyEngine.java:281)
	at org.terasology.engine.TerasologyEngine.initialize(TerasologyEngine.java:215)
	at org.terasology.engine.TerasologyEngine.run(TerasologyEngine.java:404)
	at org.terasology.engine.Terasology.main(Terasology.java:182)

I wonder if that will be fixed by #3969? Either through something LWJGL 3 deliberately does differently, or just as a by-product of creating a newer build of the .so.

@Cervator
Copy link
Member

Cervator commented Sep 7, 2020

Thanks @keturn - interesting note 🤔

Will ping @DarkWeird here as an FYI - would indeed be interesting to see if LWJGL 3 will save us all.

@keturn
Copy link
Member Author

keturn commented Feb 19, 2021

JDK 16 is now in Release Candidate phase, with less than four weeks until its scheduled General Availability release date.

As far as we know, JDK 17 is still planned to arrive in September as the next release with long term support.

Java 17 doesn't sound like such a far-off distant thing anymore!

@keturn
Copy link
Member Author

keturn commented Mar 17, 2021

Java 16 / JDK 16 is out!

jpackage, Records, instanceof pattern matching.

Vector API and foreign memory access API are in incubation stages. At this point I'd be surprised if they're included as stable in 17. Those are interesting for gamedev so I would have liked to see them in this next Long-Term Service release, but not this time, I guess.

Not much newsworthy on 17 yet. Some stuff for macs probably. We'll see what else shows up in the next few months.

@keturn
Copy link
Member Author

keturn commented Aug 10, 2021

The first release candidate for Java 17 is out!

The schedule targets August 19th for the final release candidate,
and September 14th for the release to general availability.

Highlights from the release notes include:

@Ln11211
Copy link

Ln11211 commented Sep 26, 2021

hello,
I was trying to setup my workspace with JDK 17 and I got the same error, here is what was shown on my cmd prompt...

        at org.gradle.cache.internal.DefaultCacheAccess.open(DefaultCacheAccess.
java:139)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(Defaul
tPersistentDirectoryStore.java:89)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(Defaul
tPersistentDirectoryStore.java:43)
        at org.gradle.cache.internal.DefaultCacheFactory.doOpen(DefaultCacheFact
ory.java:103)
        at org.gradle.cache.internal.DefaultCacheFactory.open(DefaultCacheFactor
y.java:68)
        at org.gradle.cache.internal.DefaultCacheRepository$PersistentCacheBuild
er.open(DefaultCacheRepository.java:126)
        at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler
.compile(FileCacheBackedScriptClassCompiler.java:116)
        at org.gradle.groovy.scripts.internal.CrossBuildInMemoryCachingScriptCla
ssCache.getOrCompile(CrossBuildInMemoryCachingScriptClassCache.java:50)
        at org.gradle.groovy.scripts.internal.BuildScopeInMemoryCachingScriptCla
ssCompiler.compile(BuildScopeInMemoryCachingScriptClassCompiler.java:50)
        at org.gradle.groovy.scripts.DefaultScriptCompilerFactory$ScriptCompiler
Impl.compile(DefaultScriptCompilerFactory.java:49)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.
apply(DefaultScriptPluginFactory.java:125)
        at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperat
ionScriptPlugin.java:65)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(
DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(
DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(Defaul
tBuildOperationRunner.java:56)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$r
un$1(DefaultBuildOperationExecutor.java:71)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWith
UnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(Defa
ultBuildOperationExecutor.java:71)
        at org.gradle.configuration.BuildOperationScriptPlugin.lambda$apply$0(Bu
ildOperationScriptPlugin.java:62)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.a
pply(DefaultUserCodeApplicationContext.java:43)
        at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperat
ionScriptPlugin.java:62)
        at org.gradle.initialization.ScriptEvaluatingSettingsProcessor.applySett
ingsScript(ScriptEvaluatingSettingsProcessor.java:74)
        at org.gradle.initialization.ScriptEvaluatingSettingsProcessor.process(S
criptEvaluatingSettingsProcessor.java:67)
        at org.gradle.initialization.SettingsEvaluatedCallbackFiringSettingsProc
essor.process(SettingsEvaluatedCallbackFiringSettingsProcessor.java:34)
        at org.gradle.initialization.RootBuildCacheControllerSettingsProcessor.p
rocess(RootBuildCacheControllerSettingsProcessor.java:47)
        at org.gradle.initialization.BuildOperationSettingsProcessor$2.call(Buil
dOperationSettingsProcessor.java:50)
        at org.gradle.initialization.BuildOperationSettingsProcessor$2.call(Buil
dOperationSettingsProcessor.java:47)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBu
ildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBu
ildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(Defau
ltBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$c
all$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWit
hUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(Def
aultBuildOperationExecutor.java:76)
        at org.gradle.initialization.BuildOperationSettingsProcessor.process(Bui
ldOperationSettingsProcessor.java:47)
        at org.gradle.initialization.DefaultSettingsLoader.findSettingsAndLoadIf
Appropriate(DefaultSettingsLoader.java:127)
        at org.gradle.initialization.DefaultSettingsLoader.findAndLoadSettings(D
efaultSettingsLoader.java:65)
        at org.gradle.initialization.SettingsAttachingSettingsLoader.findAndLoad
Settings(SettingsAttachingSettingsLoader.java:35)
        at org.gradle.internal.composite.CommandLineIncludedBuildSettingsLoader.
findAndLoadSettings(CommandLineIncludedBuildSettingsLoader.java:34)
        at org.gradle.internal.composite.ChildBuildRegisteringSettingsLoader.fin
dAndLoadSettings(ChildBuildRegisteringSettingsLoader.java:53)
        at org.gradle.internal.composite.CompositeBuildSettingsLoader.findAndLoa
dSettings(CompositeBuildSettingsLoader.java:35)
        at org.gradle.initialization.DefaultSettingsPreparer.prepareSettings(Def
aultSettingsPreparer.java:36)
        at org.gradle.initialization.BuildOperationFiringSettingsPreparer$LoadBu
ild.doLoadBuild(BuildOperationFiringSettingsPreparer.java:62)
        at org.gradle.initialization.BuildOperationFiringSettingsPreparer$LoadBu
ild.run(BuildOperationFiringSettingsPreparer.java:57)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(
DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(
DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(Defaul
tBuildOperationRunner.java:56)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$r
un$1(DefaultBuildOperationExecutor.java:71)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWith
UnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(Defa
ultBuildOperationExecutor.java:71)
        at org.gradle.initialization.BuildOperationFiringSettingsPreparer.prepar
eSettings(BuildOperationFiringSettingsPreparer.java:45)
        at org.gradle.initialization.DefaultGradleLauncher.prepareSettings(Defau
ltGradleLauncher.java:218)
        at org.gradle.initialization.DefaultGradleLauncher.doClassicBuildStages(
DefaultGradleLauncher.java:159)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:148)
        at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultG
radleLauncher.java:124)
        at org.gradle.internal.invocation.GradleBuildController$1.create(GradleB
uildController.java:72)
        at org.gradle.internal.invocation.GradleBuildController$1.create(GradleB
uildController.java:67)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultW
orkerLeaseService.java:213)
        at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBu
ildController.java:67)
        at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildC
ontroller.java:56)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(Exe
cuteBuildActionRunner.java:31)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildA
ctionRunner.java:35)
        at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(B
uildOutcomeReportingBuildActionRunner.java:63)
        at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(
ValidatingBuildActionRunner.java:32)
        at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRun
ner.run(FileSystemWatchingBuildActionRunner.java:77)
        at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.ru
n(BuildCompletionNotifyingBuildActionRunner.java:41)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(
RunAsBuildOperationBuildActionRunner.java:49)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(
RunAsBuildOperationBuildActionRunner.java:44)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBu
ildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBu
ildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(
DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(De
faultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(Defau
ltBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$c
all$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWit
hUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(Def
aultBuildOperationExecutor.java:76)
        at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(Run
AsBuildOperationBuildActionRunner.java:44)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.lambda$execute$
0(InProcessBuildActionExecuter.java:54)
        at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBu
ildState.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:53)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:29)
        at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.l
ambda$execute$0(BuildTreeScopeLifecycleBuildActionExecuter.java:33)
        at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:
49)
        at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.e
xecute(BuildTreeScopeLifecycleBuildActionExecuter.java:32)
        at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.e
xecute(BuildTreeScopeLifecycleBuildActionExecuter.java:27)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.ex
ecute(ContinuousBuildActionExecuter.java:104)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.ex
ecute(ContinuousBuildActionExecuter.java:55)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.
execute(SubscribableBuildActionExecuter.java:64)
        at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.
execute(SubscribableBuildActionExecuter.java:37)
        at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildAction
Executer.lambda$execute$0(SessionScopeLifecycleBuildActionExecuter.java:54)
        at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.j
ava:67)
        at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildAction
Executer.execute(SessionScopeLifecycleBuildActionExecuter.java:50)
        at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildAction
Executer.execute(SessionScopeLifecycleBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.
execute(GradleThreadBuildActionExecuter.java:36)
        at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.
execute(GradleThreadBuildActionExecuter.java:25)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecu
ter.execute(StartParamsValidatingActionExecuter.java:59)
        at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecu
ter.execute(StartParamsValidatingActionExecuter.java:31)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExe
cuter.execute(SessionFailureReportingActionExecuter.java:55)
        at org.gradle.tooling.internal.provider.SessionFailureReportingActionExe
cuter.execute(SessionFailureReportingActionExecuter.java:41)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execu
te(SetupLoggingActionExecuter.java:47)
        at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execu
te(SetupLoggingActionExecuter.java:31)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBu
ild.java:65)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(
WatchForDisconnection.java:39)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute
(ResetDeprecationLogger.java:29)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.
execute(RequestStopIfSingleUsedDaemon.java:35)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(Fo
rwardClientInput.java:78)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(Fo
rwardClientInput.java:75)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(For
wardClientInput.java:75)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogA
ndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClien
t.java:63)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBu
ild(EstablishBuildEnvironment.java:84)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:104)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.
run(StartBuildOrRespondWithBusy.java:52)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(Daemon
StateCoordinator.java:297)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.
onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecu
torImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoo
lExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPo
olExecutor.java:635)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnabl
e.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:833)

  1 error


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

C:\Users\user\IdeaProjects\Terasology> gradlew jar game was the cmd I executed...
I am planning to use JDK 13


Edit(skaldarnar): applied some markdown formatting to the original post for better readability

@BenjaminAmos
Copy link
Contributor

I couldn't create a new world when testing the game on JDK 17 (same with JDK 19).

23:03:30.747 [main] ERROR o.t.engine.core.modes.StateLoading - Error while loading org.terasology.engine.core.modes.loadProcesses.AwaitCharacterSpawn@2aac87ab
java.lang.IllegalArgumentException: Cannot access field java.util.concurrent.ExecutorCompletionService$QueueingFuture.task
        at org.terasology.engine.utilities.ReflectionUtil.readField(ReflectionUtil.java:497)
        at org.terasology.engine.world.chunks.pipeline.ChunkProcessingPipeline.lambda$unwrappingComporator$0(ChunkProcessingPipeline.java:93)
        at java.base/java.util.concurrent.PriorityBlockingQueue.siftUpUsingComparator(PriorityBlockingQueue.java:366)
        at java.base/java.util.concurrent.PriorityBlockingQueue.offer(PriorityBlockingQueue.java:477)
        at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1357)
        at java.base/java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:184)
        at org.terasology.engine.world.chunks.pipeline.ChunkProcessingPipeline.invokeGeneratorTask(ChunkProcessingPipeline.java:239)
        at org.terasology.engine.world.chunks.localChunkProvider.LocalChunkProvider.createOrLoadChunk(LocalChunkProvider.java:120)
        at org.terasology.engine.world.chunks.localChunkProvider.RelevanceSystem.updateRelevance(RelevanceSystem.java:135)
        at org.terasology.engine.world.chunks.localChunkProvider.RelevanceSystem.update(RelevanceSystem.java:223)
        at org.terasology.engine.core.modes.loadProcesses.AwaitCharacterSpawn.step(AwaitCharacterSpawn.java:37)
        at org.terasology.engine.core.modes.StateLoading.update(StateLoading.java:259)
        at org.terasology.engine.core.TerasologyEngine.tick(TerasologyEngine.java:512)
        at org.terasology.engine.core.TerasologyEngine.mainLoop(TerasologyEngine.java:472)
        at org.terasology.engine.core.TerasologyEngine.runMain(TerasologyEngine.java:448)
        at org.terasology.engine.core.TerasologyEngine.run(TerasologyEngine.java:414)
        at org.terasology.engine.Terasology.call(Terasology.java:190)
        at org.terasology.engine.Terasology.call(Terasology.java:70)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
        at picocli.CommandLine.access$1200(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
        at picocli.CommandLine.execute(CommandLine.java:2058)
        at org.terasology.engine.Terasology.main(Terasology.java:139)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.concurrent.Future java.util.concurrent.ExecutorCompletionService$QueueingFuture.task accessible: module java.base does not "opens java.util.concurrent" to unnamed module @2ef3eef9
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
        at org.terasology.engine.utilities.ReflectionUtil.readField(ReflectionUtil.java:491)
        ... 25 common frames omitted

/**
* BlackMagic method: {@link ExecutorCompletionService} wraps task with QueueingFuture (private access)
* there takes wrapped task for comparing in {@link ThreadPoolExecutor}
*/
private Comparator unwrappingComporator(Comparator<Future<Chunk>> comparable) {
return (o1, o2) -> {
Object unwrapped1 = ReflectionUtil.readField(o1, "task");
Object unwrapped2 = ReflectionUtil.readField(o2, "task");
return comparable.compare((Future<Chunk>) unwrapped1, (Future<Chunk>) unwrapped2);
};
}

It looks like you can't just reflect into Java internals anymore like you used to be able to.

@DarkWeird
Copy link
Contributor

It looks like you can't just reflect into Java internals anymore like you used to be able to.

Yeah. It is.

We should rewrite this part of code.
Really.. this problem can be fire in any place, which trying getting private field or access private method.

In this place.. idk how get comparable task, because some internal logic wrapping task :(

Maybe.. VarHandle with privateLookup in this future can help there...

@soloturn
Copy link
Contributor

soloturn commented Jul 8, 2023

interesting. a couple of hints here as well, including VarHandle:
https://stackoverflow.com/questions/1196192/how-to-read-the-value-of-a-private-field-from-a-different-class-in-java

@DarkWeird
Copy link
Contributor

interesting. a couple of hints here as well, including VarHandle:
https://stackoverflow.com/questions/1196192/how-to-read-the-value-of-a-private-field-from-a-different-class-in-java

Yeah. It is interesting feature.
I known several places where we can use it instead bytecode generation (like reflectasm for event handlers)
But don't sure that changing private fields is right place in any way. Especially it is our code.

@BenjaminAmos
Copy link
Contributor

This main issue is this part:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.concurrent.Future java.util.concurrent.ExecutorCompletionService$QueueingFuture.task accessible: module java.base does not "opens java.util.concurrent" to unnamed module @2ef3eef9

Newer Java versions are much more strict about how you can interact with modules. Private access via reflection is now almost completely forbidden. I agree that the right solution is indeed to not be accessing private implementation details at all.

@jdrueckert
Copy link
Member

Being addressed with #5162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. Size: L Very big effort likely requiring a lot of research and work in many areas across the codebase Status: Needs Investigation Requires to be debugged or checked for feasibility, etc.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

9 participants