delombok does not create compilable code for Exercise<T> from DataExample #213

lombokissues opened this Issue Jul 14, 2015 · 5 comments


None yet

1 participant


Migrated from Google Code (issue 140)


๐Ÿ‘ค ย  ๐Ÿ•— Aug 12, 2010 at 06:36 UTC

What steps will reproduce the problem?

  1. Run delombok against the DataExample class found here:
  2. Attempt to compile the delombok'd java code and you will get a compilation error:[23,16] incompatible types
found : T
required: T

I would seem that there is a syntax error with this:

private <T>Exercise(final String name, final T value) { = name;
this.value = value;

I must admit that I don't understand why the compiler is complaining (Found T, Required T makes me wonder if the compiler is buggy, but...)

I'm using Lombok 0.9.3 and Javac 1.6.0_21 on Windows 7.


๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 13, 2010 at 02:05 UTC

@lombokissues lombokissues added this to the 0.9.4 milestone Jul 14, 2015

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 13, 2010 at 02:07 UTC

Ugh, this is a javac bug. We've tackled a few, but we must have missed this one. We rely on javac to turn one of its own ASTs back into a compilable source file, and it doesn't always get this right. It looks like its injecting an erroneous type variable into the compiler.

In case you are wondering, what's happening here is that the class has a type var named 'T', and the 'value' field is of this type 'T'. The constructor has its own type var, also named 'T' which is shadowing the classes T. You haven't seen this because this is an extremely obscure java feature nobody ever uses (constructors with their own type vars). the value parameter is of this shadowed T. The complaint will be on the "this.value = value;" line. The field (left of =) is of the class's T, whereas the parameter (right of =) is of the constructor's T. These Ts are completely unrelated, and thus they aren't compatible, though in the error message this isn't clear, as they are both named T.

The mistake is in javac emitting that in the first place, which it should not be doing.

We're planning on ditching javac for this part of delombok in the next release, which would resolve this problem. But if we don't, we'll definitely patch the printer. Thanks for spotting it!


๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 14, 2010 at 02:05 UTC

Fixed in commit 2043399

@lombokissues lombokissues removed the accepted label Jul 14, 2015

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment