Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a limit to the complexity of a type to be inferred by Lombok's val?

Tags:

gradle

lombok

I have a Data Access Object written using jOOQ and it returns a rather complex type signature:

Map<Record, Result<Record14<String, Integer, String, String, String, String, String, String, Integer, String, Boolean, Boolean, Integer, Boolean>>> result = create....

I tried to replace it with Lombok's "val"

val result = create....

This works when I run/compile from Eclipse... When I try to compile within Gradle, I get:

UpdatesDAO.java:307: error: incompatible types
            .fetchGroups(key);
                        ^
  required: val
  found: Map<Record,Result<Record14<String,Integer,String,String,String,String,String,String,Integer,String,Boolean,Boolean,Integer,Boolean>>>

Can anyone tell me why it would work in Gradle for simpler types, but not for more complex types? I have other places in this same project which look something like:

val records = dao.getDatastoreById(id); // Returns a type of List<Datastore>

and they work just fine, even when compiled with Gradle... Am I missing something?

FYI: Lombok version = 1.14.8, Gradle version 2.2.1

I have tried lombok==1.14.6, Gradle version 2.2.0

I have also tried with both Java 8 and Java 7, both OpenJDK and Oracle JDK

like image 579
Deven Phillips Avatar asked Dec 16 '14 18:12

Deven Phillips


1 Answers

The answer is a conflict between jOOQ's DSL and lombok.. The jOOQ DSL has a method "val" which will cause a conflict when imported statically:

import static org.jooq.impl.DSL.val;

If you are using that "val" method via a static import it will break lombok's "val" implementation. Removing that static import and using "DSL.val()" instead resolved the issue for me.

More information available at: https://code.google.com/p/projectlombok/issues/detail?id=762

like image 132
Deven Phillips Avatar answered Oct 19 '22 23:10

Deven Phillips