akshattandon / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

Chained use of statically imported XArgsConstructor using staticName crashes JavaC #768

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Description of the problem

Currently, whenever the static helper method which constructs the class is 
chained, compilation using javac crashes.

The delomboked code compiles correctly using javac.

While seemingly similar to issue 721, it is different.

What steps will reproduce the problem?
1. Compiling the below code in maven, with a clean project. (If precompiled 
with the eclipse compiler, it works. But this is not a solution obviously.)

Code Example: 

package test;
import lombok.AllArgsConstructor;

@AllArgsConstructor(staticName = "a")
public class A {
    int a;
}

-----

package test;
import static test.A.a;
import lombok.AllArgsConstructor;

@AllArgsConstructor(staticName = "b")
public class B {

    A b;

    public static void main(String[] args) {
        B b = b(a(0));
    }

}

What is the expected output? What do you see instead?
Correct compilation, instead:

[ERROR] lombok-error-static/src/main/java/test/B.java:[3,1] cannot find symbol
  symbol:   static a
  location: class
[ERROR] lombok-error-static/src/main/java/test/B.java:[13,25] cannot find symbol
  symbol:   method a(int)
  location: class test.B

What version of the product are you using? On what operating system?

Apache Maven 3.2.5
Maven home: /opt/maven
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.17.6-1-arch", arch: "amd64", family: "unix"

Original issue reported on code.google.com by Lume...@gmail.com on 13 Jan 2015 at 1:32

GoogleCodeExporter commented 9 years ago
Even though the problem is different from issue 721, the underlying cause is 
the same. Javac7 first processes the static imports and only later runs 
annotation processors, provided all static imports were fine. However, if a 
static import is missing it does not run annotation processors at all, even 
though the annotation processor might generate the code to make the static 
import work.

Original comment by r.spilker on 21 Jan 2015 at 1:33

GoogleCodeExporter commented 9 years ago
I would understand this to be a problem if the static import was cyclical, 
however the static import is stand alone, and has no dependencies on B, the 
importing class.

According to the bug tracker, this would be fixed in JDK 8 b43; does this bug 
still occur on later builds? (As far as I can tell only JDK9 previews are 
releases after b43.)

Original comment by Lume...@gmail.com on 21 Jan 2015 at 10:41