Skip to content

Terasology now uses Java 17 #5177

Closed
Closed

Description

@BenjaminAmos

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

Activity

  1. added
    Category: DocRequests, Issues and Changes targeting javadoc and module documentation
    Status: Needs DiscussionRequires help discussing a reported issue or provided PR
    on Nov 17, 2023
  2. BenjaminAmos commented on Nov 17, 2023

    @BenjaminAmos
    ContributorAuthor
  3. added
    Category: Build/CIRequests, Issues and Changes targeting gradle, groovy, Jenkins, etc.
    Breaking ChangeAPI breaking change requiring follow-up work in dependant areas
    on Nov 17, 2023
  4. jdrueckert commented on Nov 18, 2023

    @jdrueckert
    Member

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

  5. soloturn commented on Nov 18, 2023

    @soloturn
    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?

  6. BenjaminAmos commented on Nov 18, 2023

    @BenjaminAmos
    ContributorAuthor

    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..

  7. lokytech5 commented on Nov 19, 2023

    @lokytech5

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

  8. BenjaminAmos commented on Nov 19, 2023

    @BenjaminAmos
    ContributorAuthor

    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.

  9. lokytech5 commented on Dec 6, 2023

    @lokytech5

    ok noted

  10. soloturn commented on Dec 28, 2023

    @soloturn
    Contributor

    @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)
    
  11. BenjaminAmos commented on Jan 2, 2024

    @BenjaminAmos
    ContributorAuthor
    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.

  12. soloturn commented on Mar 11, 2024

    @soloturn
    Contributor

    nothing known which is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeAPI breaking change requiring follow-up work in dependant areasCategory: Build/CIRequests, Issues and Changes targeting gradle, groovy, Jenkins, etc.Category: DocRequests, Issues and Changes targeting javadoc and module documentationStatus: Needs DiscussionRequires help discussing a reported issue or provided PR

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions