[Solved] NoSuchFieldError: Class JCTree$JCImport does not have member field

When rebuilding a Java or Spring application, after upgrading Java 21, you may face this issue “NoSuchFieldError: Class JCTree$JCImport does not have member field” during the build process. Let’s learn to fix it.

1. The Error

When building the project, after the JDK 21 upgrade, the build error looks like this:

java: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport 
  does not have member field 'com.sun.tools.javac.tree.JCTree qualid'

2. The Root Cause

The com.sun.tools.javac.tree.JCTree$JCImport class, including its ‘qualid’ field, is part of the internal implementation of the Java compiler (javac). It stores the internal representation of Java source code in the Abstract Syntax Tree (AST) form. It’s not intended for general use in regular programming tasks.

To provide its functionality using annotations, Lombok accesses this internal JDK API (com.sun.tools.javac.tree.JCTree$JCImport) with reflection access to its field ‘qualid’. [Link]

The field has been changed in Java 21. Till Java 20, it was of type JCTree. In Java 21, its type has been changed to JCFieldAccess. [Issue-3393]

public JCTree qualid;  //Java 20 and before

public JCFieldAccess qualid;  //Java 21 and Later

The corresponding changes have been done in ‘Lombok 1.18.30‘ [Change log].

3. The Solution

To solve this error, we need to upgrade the Lombok version to 1.18.30 or later. The issue has been fixed in that version.

The recommendation is to always update to the latest version of Lombok.

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.32'

Do not forget to update the version in maven-compiler-plugin also if you have added it to the project.


plugins {
    id 'java'

dependencies {
    annotationProcessor 'org.projectlombok:lombok:1.18.32'
    implementation 'org.projectlombok:lombok:1.18.32'

4. Conclusion

This short Java tutorial discussed the ‘NoSuchFieldError: Class JCTree$JCImport does not have member field’ caused by Lombok and how to fix it by updating the Lombok version in dependencies file.

Happy Learning !!


Notify of
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.