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

[1.19.2] Fixed submitted chat event incompatible with jarInJar #9691

Open
wants to merge 1 commit into
base: 1.19.2
Choose a base branch
from

Conversation

Icosider
Copy link

@Icosider Icosider commented Aug 5, 2023

I have identified an error when using the ServerChatEvent.Submitted event with JarInJar dependencies. The essence of the error is that if we cancel this event and add code from the JarInJar dependency, we will get a ClassNotFoundException error. This error was detected when using Kotlin as a JarInJar dependency. Perhaps in the current PR it is worth replacing Util#ioPool from Minecraft with your own ExecutorService.

In addition, I would like to say that using CompletableFuture without your own ExecutorService is a bad practice.

Testing version: 1.19.2

Using ForkJoinPool
Configuration gradle:

dependencies {
    jarJar("org.jetbrains:annotations:[24.0.1]")
    jarJar("org.jetbrains.kotlin:kotlin-stdlib:[1.9.0]")
    jarJar("org.jetbrains.kotlin:kotlin-stdlib-common:[1.9.0]")
    jarJar("org.jetbrains.kotlin:kotlin-stdlib-jdk7:[1.9.0]")
    jarJar("org.jetbrains.kotlin:kotlin-stdlib-jdk8:[1.9.0]")
    jarJar("org.jetbrains.kotlin:kotlin-reflect:[1.9.0]")
    jarJar("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:[1.7.2]")
    jarJar("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:[1.7.2]")
    jarJar("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:[1.7.2]")
    jarJar("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:[1.5.1]")
    jarJar("org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:[1.5.1]")
}

Mod code:

@Mod("test")
class FjkTest {
    init {
        MinecraftForge.EVENT_BUS.addListener(::onServerStarting)
    }

    private fun onServerStarting(event: ServerStartingEvent) {
        CompletableFuture.runAsync {
            testException { text ->
            }
        }
    }

    private fun testException(block: String.() -> Unit) {
        println("I will printed with exception")
    }
}

Build mod, run outside the IDE and join to world. Look at logs and check stacktrace with ClassNotFoundException: kotlin.blablabla.Lambda

Using normal ExecutorService
Configuration gradle: look at message above

Mod code:

import net.minecraft.Util

@Mod("test")
class ExecServiceTest {
    init {
        MinecraftForge.EVENT_BUS.addListener(::onServerStarting)
    }

    private fun onServerStarting(event: ServerStartingEvent) {
        CompletableFuture.runAsync({
            testException { text ->
            }
        }, Util.ioPool())
    }

    private fun testException(block: String.() -> Unit) {
        println("I will printed without exception")
    }
}

@CLAassistant
Copy link

CLAassistant commented Aug 5, 2023

CLA assistant check
All committers have signed the CLA.

@PaintNinja PaintNinja added 1.19 Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. LTS This issue/PR is related to the current LTS version. labels Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.19 LTS This issue/PR is related to the current LTS version. Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants