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

Lazy Getter + NetBeans = Error parsing file #1696

Open
Lilianne-Blaze opened this issue May 21, 2018 · 5 comments
Open

Lazy Getter + NetBeans = Error parsing file #1696

Lilianne-Blaze opened this issue May 21, 2018 · 5 comments

Comments

@Lilianne-Blaze
Copy link

When using NetBeans 8.2 with Maven + Lombok with the following code

@getter(lazy = true)
private final String calculated = doCalculate();

private String doCalculate()
{
return this.toString();
}

NetBeans show red ! with "Error parsing file" in Projects view

Also there's (classname).java.err in NB's cache directory with:

ERROR:30:variable calculated is already defined in class lombok_test.LombokTestBean
ERROR:29:cannot find symbol\n symbol\d method get()\n location\d variable calculated of type java.lang.String

Is it because NB sees both "String calculated" and "AtomicReference calculated"?
If so, could you change it so that generated field is called something like "AtomicReference calculatedRef"?

@victorwss
Copy link
Contributor

Can you add the whole file that produces this problem? I can't understand what or where is your AtomicReference calculated.

@Maaartinus
Copy link
Contributor

@victorwss

calculated is cached from this example

@Lilianne-Blaze

Is it because NB sees both "String calculated" and "AtomicReference calculated"?

The original field should be replaced by the AtomicReference and this normally works, at least I can't recall any issue concerning this.

If so, could you change it so that generated field is called something like "AtomicReference calculatedRef"?

This would surely be wrong. The original field must be simply removed and this works for me. I don't work myself on lombok, but the project maintainers would surely need more details like the used java version and possibly other interfering annotation processors.

@Lilianne-Blaze
Copy link
Author

package com.example.lomboklazygetandnb;

@lombok.extern.java.Log
public class LombokLazyGetAndNB
{

private static final String NETBEANS = "8.2 patch 2";

private static final String JAVA = "1.8.0_172 x64";

private static final String WINDOWS = "Windows 10 Pro x64";

private static final String NB_SETTINGS = "turn off Compile on Save";

// when set to true NB shows red ! with "Error parsing file." in Projects view
// when set to false it doesn't
@lombok.Getter(lazy = true)
private final String calculated = initCalculated();

private String initCalculated()
{
return "! " + new java.util.Date() + " !! " + Math.random();
}

public static void main(String[] args)
{
System.err.println("main...");

LombokLazyGetAndNB instance = new LombokLazyGetAndNB();
System.out.println("calculated = " + instance.getCalculated());

}

}

@totakura
Copy link

Hi, this issue still exists with lombok-1.18.18 and Netbeans-12.3. I compile a sample project that reproduces this here: https://github.com/totakura/nb-lombok-lazy-getter

@totakura
Copy link

totakura commented Mar 28, 2021

I also opened a bug report for Netbeans: https://issues.apache.org/jira/browse/NETBEANS-5512

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

4 participants