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

[BUG] cannot find symbol #3117

Closed
GameurDuXVI opened this issue Feb 19, 2022 · 1 comment
Closed

[BUG] cannot find symbol #3117

GameurDuXVI opened this issue Feb 19, 2022 · 1 comment

Comments

@GameurDuXVI
Copy link

GameurDuXVI commented Feb 19, 2022

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.*;

@Rawi01
Copy link
Collaborator

Rawi01 commented Feb 21, 2022

This is a duplicate of #2044

@Rawi01 Rawi01 closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants