Skip to content

1.58.0: Java Builder crashes with ClassCastException (BlockScope → MethodScope) compiling Lombok @SneakyThrows constructor — stuck at "Building 0%", works fine on 1.56.0 #4558

Open

Description

@v-huizhu2

After upgrading the extension from 1.56.0 to 1.58.0, the Java Builder crashes while compiling
any class that has a Lombok @SneakyThrows constructor whose body assigns final fields /
performs potentially-throwing calls. The builder failure puts the workspace into a build loop:
the status bar flickers between "Java: Building - 0%" and "Java: Ready", and hundreds of
cascading false errors appear (e.g. Cannot invoke setUserType(Integer) on the primitive type void, The project cannot be built until its prerequisite ... is built).

The exact same workspace builds cleanly with Maven (mvn clean compile, JDK 21) and with
extension 1.56.0. Downgrading to 1.56.0 makes all problems disappear.

To Reproduce

import lombok.SneakyThrows;

public abstract class AbstractRedisChannelMessageListener<T> {

    private final Class<T> messageType;
    private final String channel;

    @SneakyThrows
    protected AbstractRedisChannelMessageListener() {
        this.messageType = getMessageClass();
        this.channel = messageType.getDeclaredConstructor().newInstance().toString();
    }

    private Class<T> getMessageClass() {
        return null;
    }
}

Stack trace (from jdt_ws/.metadata/.log, repeating every build cycle):

java.lang.RuntimeException: Internal Error compiling /yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/redis/core/pubsub/AbstractRedisChannelMessageListener.java
	at org.eclipse.jdt.internal.compiler.ProcessTaskManager.processing(ProcessTaskManager.java:139)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: class org.eclipse.jdt.internal.compiler.lookup.BlockScope
cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.MethodScope
(org.eclipse.jdt.internal.compiler.lookup.BlockScope and org.eclipse.jdt.internal.compiler.lookup.MethodScope
are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @1b09b7b8)

(On later builds the ClassCastException message is empty, same stack.)

Suspected cause

1.58.0 runs the language server on the bundled JRE 25 with a recent ECJ that implements
JEP 513 (Flexible Constructor Bodies). Lombok's @SneakyThrows handler wraps the constructor
body in a try/catch, which likely hits the new constructor-body code path in ECJ, producing
a BlockScope where the handler expects a MethodScope. The bundled lombok agent is
lombok-1.18.39-4050.jar; the project itself uses Lombok 1.18.42.

Possibly related to the 1.57.0 Lombok regression wave (#4545, #4549, #4543, #4521, #4504),
but the BlockScope → MethodScope crash itself is not covered by any of them and still
occurs on 1.58.0.

Environment

  • Extension version: 1.58.0 (regression vs 1.56.0, which works)
  • VS Code version: 1.143.1 (e646868227c3e3a9e3f24277c8c7220be42c0be7)
  • OS: macOS 26.7.1 (arm64, Apple Silicon)
  • Language server JVM: bundled JRE 25.0.4.1 (macosx-aarch64)
  • Project: Maven multi-module, Java release 21, Lombok 1.18.42 on the classpath
  • Server launch flags include: -javaagent:.../redhat.java-1.58.0-darwin-arm64/lombok/lombok-1.18.39-4050.jar

Workaround

Pin the extension to 1.56.0 (code --install-extension redhat.java@1.56.0) and disable
auto-update for the extension.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions