Skip to content

[BUG] cannot find symbol #3117

Description

@GameurDuXVI

Describe the bug
The error "cannot find symbol" is triggered on compiling of maven.

To Reproduce
An example of the bug has been made in a test project that is able on this link: https://www.dropbox.com/s/gu1m48h2wlgtnlf/TestLombok.rar?dl=1

So firstly we make a class that is annotated with @UtilityClass, then make a random function like this.

package en.test.lombok;

import lombok.experimental.UtilityClass;

@UtilityClass
public class Utility {

    public void anyFunction(){

    }
}

After we need to call the function anyFunction using a static import in another class like this.

package en.test.lombok;

import static en.test.lombok.Utility.anyFunction;

public class Main {

    public static void main(String[] args) {

    }
}

After we configure the pom to use the annotation processors:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>TestLombok</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.22</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
</project>

An it should not compile due to the "cannot find symbol" error.

Expected behavior
It should just compile normally.

Version info (please complete the following information):

  • Lombok 1.18.22
  • Java version "1.8.0_291"
  • javac 11.0.13

Additional context
This can be fixed by just using the * instead on the function name like this:
import static en.test.lombok.Utility.*;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions