LabyStudio / singlehotswap

With this plugin you can hotswap 50x faster than usual by hotswapping only the file opened in the editor with the internal compiler of IntelliJ. It will provide a blue hammer next to the green "Build Project" hammer.
37 stars 5 forks source link

Sudden, unexplained "Compilation failed" when trying to swap classes #21

Open Decencies opened 4 months ago

Decencies commented 4 months ago

I had been using this plugin to swap a few classes. After a few restarts of the application, I can no longer swap the same classes I was working on due to "Compilation failed".

The classes I am trying to swap do not have any syntax errors. I am running OpenJDK 17.0.7 on Windows 10 64-bit.

LabyStudio commented 4 months ago

I couldn't find a way to reproduce it. Do you have a simplified example project setup that causes the issue?

Decencies commented 4 months ago

No idea how to reproduce, I just closed all instances of intellij and restarted the applet and it started working again.

LabyStudio commented 3 months ago

Seems like updating IntelliJ could fix the issue #22

JoeTheOrangeCat commented 2 weeks ago

Seems like updating IntelliJ could fix the issue #22

Its happing to me again too :( im using the 2024 version, Ill see what happens when I downgrade maybe

JoeTheOrangeCat commented 2 weeks ago

Ok a different project runs fine, but this one doesn't... even though there are no errors. hmmm

LabyStudio commented 2 weeks ago

If you can give me an example project where this is the case, I can take a look at it

JoeTheOrangeCat commented 2 weeks ago

Is there a way you can make the message show where the compilation error is? Or even what file its in? Because there is no error showing up for me.

I'll let you know if I find anything because I'm not sure how to replicate it.

JoeTheOrangeCat commented 2 weeks ago
java.lang.Throwable: net.labymod.intellij.singlehotswap.hotswap.FileType <clinit> requests com.intellij.ide.plugins.PluginManager instance. Class initialization must not depend on services. Consider using instance of the service on-demand instead.
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
    at com.intellij.serviceContainer.ComponentManagerImplKt.checkOutsideClassInitializer(ComponentManagerImpl.kt:1588)
    at com.intellij.serviceContainer.ComponentManagerImplKt.getOrCreateInstanceBlocking(ComponentManagerImpl.kt:1557)
    at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:746)
    at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:690)
    at com.intellij.ide.plugins.PluginManager.getInstance(PluginManager.java:30)
    at net.labymod.intellij.singlehotswap.hotswap.FileType.<init>(FileType.java:50)
    at net.labymod.intellij.singlehotswap.hotswap.FileType.<clinit>(FileType.java:16)
    at net.labymod.intellij.singlehotswap.actions.SingleHotswapAction.update(SingleHotswapAction.java:68)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$performDumbAwareUpdate$runnable$1.invoke(ActionUtil.kt:199)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$performDumbAwareUpdate$runnable$1.invoke(ActionUtil.kt:193)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareUpdate(ActionUtil.kt:217)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$success$1$1$1.invoke(ActionUpdater.kt:561)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$success$1$1$1.invoke(ActionUpdater.kt:560)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$callAction$2$1.invoke(ActionUpdater.kt:155)
    at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:104)
    at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$2.invoke(InternalReadAction.kt:94)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$2.invoke(InternalReadAction.kt:93)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$2$lambda$1$lambda$0(cancellableReadAction.kt:31)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:291)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$2$lambda$1(cancellableReadAction.kt:29)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:66)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:155)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:27)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:93)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:77)
    at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:64)
    at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$3.invokeSuspend(InternalReadAction.kt:35)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$3.invoke(InternalReadAction.kt)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$3.invoke(InternalReadAction.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:261)
    at com.intellij.openapi.application.rw.InternalReadAction.runReadAction(InternalReadAction.kt:34)
    at com.intellij.openapi.application.rw.PlatformReadWriteActionSupport.executeReadAction(PlatformReadWriteActionSupport.kt:38)
    at com.intellij.openapi.application.ReadWriteActionSupport.executeReadAction$default(ReadWriteActionSupport.kt:15)
    at com.intellij.openapi.application.CoroutinesKt.constrainedReadActionUndispatched(coroutines.kt:82)
    at com.intellij.openapi.application.CoroutinesKt.readActionUndispatched(coroutines.kt:69)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$callAction$$inlined$useWithScope$1.invokeSuspend(trace.kt:163)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$callAction$$inlined$useWithScope$1.invoke(trace.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$callAction$$inlined$useWithScope$1.invoke(trace.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.callAction(ActionUpdater.kt:939)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.access$callAction(ActionUpdater.kt:85)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$success$1$1.invokeSuspend(ActionUpdater.kt:560)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$success$1$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$success$1$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$$inlined$retryOnAwaitSharedData$1.invokeSuspend(ActionUpdater.kt:939)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$$inlined$retryOnAwaitSharedData$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateAction$$inlined$retryOnAwaitSharedData$1.invoke(ActionUpdater.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.updateAction(ActionUpdater.kt:979)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandGroupChild(ActionUpdater.kt:407)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.access$expandGroupChild(ActionUpdater.kt:85)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$doExpandActionGroup$2$expandResult$1$1.invokeSuspend(ActionUpdater.kt:334)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:608)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:873)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:763)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:750)
JoeTheOrangeCat commented 2 weeks ago

That was on start

LabyStudio commented 2 weeks ago

It looks like you have an old version of the plugin

JoeTheOrangeCat commented 2 weeks ago

Ill see if I can update it

JoeTheOrangeCat commented 2 weeks ago

Ok I updated it, along with Gradlew(to 8.8) but I still get Error during hotswap: Compilation failed

JoeTheOrangeCat commented 2 weeks ago

Hold on gradle is doing something

JoeTheOrangeCat commented 2 weeks ago

Nope same error, Ill try to see if I can fix it later.

LabyStudio commented 2 weeks ago

I can add some debugging messages for you

JoeTheOrangeCat commented 2 weeks ago

Thanks! I will try tomorrow or the next day! I also deleted all grades cache, the .ide folder and maybe something else to let the regenerate but the problem persisted. Probably tomorrow I'll try the debug messages and get back to you.

LabyStudio commented 2 weeks ago

singlehotswap.zip

JoeTheOrangeCat commented 2 weeks ago

Thanks! I'll try that tomorrow.

JoeTheOrangeCat commented 2 weeks ago

fabric-example-mod-1.19 [runClient]: Error during compilation: null:-1 SpongePowered MIXIN Annotation Processor Version=0.8.5 null:-1 Supported obfuscation types: ObfuscationServiceMCP supports [searge,notch] file:/C:/Users/*/Desktop/Java/*/fabric-example-mod-1.19/src/main/java/net/*/mixin/ConnectionMixin.java:21 Unable to locate obfuscation mapping for @Inject target send

Hmm interesting, the debug info was helpful! Its something to do with the mixins.

JoeTheOrangeCat commented 2 weeks ago

@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", cancellable = true) public void send(Packet<?> packet, @Nullable PacketCallbacks callbacks, CallbackInfo ci) { .... }

/\ errors

\/ doesn't error

@Inject(at = @At("HEAD"), method = "getClientModName", cancellable = true, remap = false)
    private static void getClientModName(CallbackInfoReturnable<String> callback) {

    }
JoeTheOrangeCat commented 2 weeks ago

I had a bit of extra time to test it today

JoeTheOrangeCat commented 2 weeks ago

Ok I tested it on the one I thought was working, turns out its also erroring on certain Mixins.

JoeTheOrangeCat commented 2 weeks ago

Gronk [runClient]: Error during compilation: null:-1 SpongePowered MIXIN Annotation Processor Version=0.8.5 null:-1 Supported obfuscation types: ObfuscationServiceMCP supports [searge,notch] file:/C:/Users/*/Desktop/Java/Gronk/src/main/java/com/example/mixin/ExampleMixin.java:11 Unable to locate obfuscation mapping for @Inject target loadWorld

@Mixin(MinecraftServer.class)
public class ExampleMixin {
    @Inject(at = @At("HEAD"), method = "loadWorld")
    private void init(CallbackInfo info) {
        // This code is injected into the start of MinecraftServer.loadWorld()V
    }
}

I just don't have many mixins in this project so I didn't notice.

LabyStudio commented 2 weeks ago

What happens if you use a different compiler? It would be surprising if the built-in compiler could handle Mixins. You can also enable the option to hold shift while hotswapping to switch between the built-in compiler and your default compiler image

JoeTheOrangeCat commented 2 weeks ago

fabric-example-mod-1.19 [runClient]: Compiled 1 classes in 1531ms fabric-example-mod-1.19 [runClient]: 0 classes reloaded

Thats when I turn Built-In compiler off, however no changes seemed to have been made

LabyStudio commented 2 weeks ago

Yep, that's what I expected. I'm pretty sure it's not possible to hotswap Mixins with this configuration. Maybe there is a way to solve it, but I've never tried that. I think @R0bbyYT managed to do it somehow.

JoeTheOrangeCat commented 2 weeks ago

I think I used to be able to hotswap mixins, but I haven't been able to recently. It's also only certain mixins too.