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

Terasology now uses Java 17 #5177

Closed
BenjaminAmos opened this issue Nov 17, 2023 · 10 comments
Closed

Terasology now uses Java 17 #5177

BenjaminAmos opened this issue Nov 17, 2023 · 10 comments
Labels
Breaking Change API breaking change requiring follow-up work in dependant areas Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Status: Needs Discussion Requires help discussing a reported issue or provided PR

Comments

@BenjaminAmos
Copy link
Contributor

Documentation Topic

As of #5162 being merged, Terasology now uses Java 17 for compilation. Whilst some documentation has been updated for this, there is likely more still that references Java 11 in places.

After pulling in 3aa68c0, or with a fresh clone, you will need a Java 17 JDK to build and run the game. JDK 17 can be obtained from many sources. I personally find that the Eclipse Termurin (formerly AdoptOpenJDK) distribution tends to work.

If you are seeing errors like the following then you are probably still using JDK 11. You need to update to JDK 17 to fix this (make sure to update the JAVA_HOME environment variable as well).

A problem occurred configuring root project 'Terasology'.
> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':classpath'.
      > Could not resolve org.terasology.gradology:build-logic.
        Required by:
            project :
         > No matching variant of project :build-logic was found. The consumer was configured to find a library for use during runtime, compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.4' but:
             - Variant 'apiElements' capability org.terasology.gradology:build-logic:unspecified declares a library, packaged as a jar, and its dependencies declared externally:
                 - Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 11
                 - Other compatible attribute:
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
             - Variant 'mainSourceElements' capability org.terasology.gradology:build-logic:unspecified declares a component, and its dependencies declared externally:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 11)
                     - Doesn't say anything about its elements (required them packaged as a jar)
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')
                     - Doesn't say anything about its usage (required runtime)

You may also see the following warning. We're aware of it and it is unlikely to be resolved soon. The game depends on SecurityManager as a part of module sandboxing.

WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.terasology.engine.core.module.ModuleManager (file:/engine/build/libs/engine-5.4.0-SNAPSHOT.jar)
WARNING: Please consider reporting this to the maintainers of org.terasology.engine.core.module.ModuleManager
WARNING: System::setSecurityManager will be removed in a future release

Documentation Type

Terasology Knowledge Base

@BenjaminAmos BenjaminAmos added Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Status: Needs Discussion Requires help discussing a reported issue or provided PR labels Nov 17, 2023
@BenjaminAmos
Copy link
Contributor Author

@soloturn @PurityLake @lokytech5 @jdrueckert @skaldarnar - this might affect you.

@BenjaminAmos BenjaminAmos added Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. Breaking Change API breaking change requiring follow-up work in dependant areas labels Nov 17, 2023
@jdrueckert
Copy link
Member

Provided @skaldarnar and I write a milestone summary blogpost again, that's definitely going in there in bold 😅

@soloturn
Copy link
Contributor

thanks for the heads up @BenjaminAmos ! as i never have a JAVA_HOME set i am wondering why you recommend to do so for terasology?

@BenjaminAmos
Copy link
Contributor Author

thanks for the heads up @BenjaminAmos ! as i never have a JAVA_HOME set i am wondering why you recommend to do so for terasology?

I did not intend to recommend it, just to advise that the variable should be changed if it exists. When working with multiple Java versions, setting the JAVA_HOME environment variable can be an easy way to switch between versions. Certain tools used to depend on the presence of the variable to identify where Java was installed. Most of the time having the right java install directory in your system path (the PATH environment variable) works the same..

@lokytech5
Copy link

May I know the actual Java version to set in JAVA_HOME?

@BenjaminAmos
Copy link
Contributor Author

If you have a JAVA_HOME environment variable set then you should change it to the location that Java 17 is installed in. For example, on Windows it might be installed in C:\Program Files\Eclipse Adoptium\jdk-17.0.8.101-hotspot. If you don't have that environment variable present then you do not need to do anything with it.

@lokytech5
Copy link

ok noted

@soloturn
Copy link
Contributor

soloturn commented Dec 28, 2023

@BenjaminAmos , when exiting the game using "josharias survival" i get the following error:

11:16:51.570 [main] INFO  o.t.engine.core.TerasologyEngine - Shutting down Terasology...
11:16:51.595 [Chunk-Processing-Reactor] ERROR o.t.e.w.c.p.ChunkProcessingPipeline - Reactor thread was interrupted
java.lang.InterruptedException: null
        at java.base/java.util.concurrent.locks.ReentrantLock$Sync.lockInterruptibly(ReentrantLock.java:159)
        at java.base/java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:372)
        at java.base/java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:531)
        at org.terasology.engine.world.chunks.pipeline.ChunkExecutorCompletionService.take(ChunkExecutorCompletionService.java:83)
        at org.terasology.engine.world.chunks.pipeline.ChunkProcessingPipeline.chunkTaskHandler(ChunkProcessingPipeline.java:82)
        at java.base/java.lang.Thread.run(Thread.java:840)
11:16:51.703 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Saving - Creating game snapshot
11:16:51.780 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Saving - Snapshot created: Writing phase starts
11:16:51.815 [parallel-1] ERROR reactor.core.publisher.Operators - Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.Class java.lang.Class.componentType accessible: module java.base does not "opens java.lang" to unnamed module @f0da945
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.Class java.lang.Class.componentType accessible: module java.base does not "opens java.lang" to unnamed module @f0da945
        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.persistence.typeHandling.coreTypes.factories.ObjectFieldMapTypeHandlerFactory.lambda$getResolvedFields$1(ObjectFieldMapTypeHandlerFactory.java:80)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at org.terasology.persistence.typeHandling.coreTypes.factories.ObjectFieldMapTypeHandlerFactory.getResolvedFields(ObjectFieldMapTypeHandlerFactory.java:68)

@BenjaminAmos
Copy link
Contributor Author

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.Class java.lang.Class.componentType accessible: module java.base does not "opens java.lang" to unnamed module @f0da945
        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.persistence.typeHandling.coreTypes.factories.ObjectFieldMapTypeHandlerFactory.lambda$getResolvedFields$1(ObjectFieldMapTypeHandlerFactory.java:80)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at org.terasology.persistence.typeHandling.coreTypes.factories.ObjectFieldMapTypeHandlerFactory.getResolvedFields(ObjectFieldMapTypeHandlerFactory.java:68)

There is likely a component somewhere that contains a java.lang.Class field within it. This does look like a Java 17 issue though.

I think this might have been related to RetainComponentsComponent when I last checked.

@soloturn
Copy link
Contributor

nothing known which is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change API breaking change requiring follow-up work in dependant areas Category: Build/CI Requests, Issues and Changes targeting gradle, groovy, Jenkins, etc. Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Status: Needs Discussion Requires help discussing a reported issue or provided PR
Projects
Status: No status
Development

No branches or pull requests

4 participants