i'm using eclipse , have mulitmodule maven project in use lombok(1.16.4) java=jdk1.7.0_71.
in eclipse code compiles , junit testes pass. in maven (v. 3.2.3 , 3.3.3) code not compile.
[error] compilation error : [info] ------------------------------------------------------------- [error] determinemarketdirection.java:[86,42] cannot find symbol symbol: method sumvaluesdouble(java.lang.string) location: variable listtoworkon of type java.util.list<t> [info] 1 error this sumvaluesdouble lombok's extension method type list<> defined in module a. error above occures in module c depends on module a.
this part of extensionlist.java:
public static <t> double sumvaluesdouble(list<t> list, final string methodname) { return sumvaluesof(list, methodname, double.class); } private static <t, n extends number> n sumvaluesof(list<t> list, final string methodname, class<n> type) { function<t, n> transform = new function<t, n>() { @suppresswarnings("unchecked") @override @sneakythrows public n apply(t from) { method method = from.getclass().getmethod(methodname); return (n) method.invoke(from); } }; list<n> projectedlist = lists.transform(list, transform); return sumall(projectedlist); } it's strange because have tests in module a extension method , compile ok , pass.
part of test module a:
@extensionmethod({ extensionlist.class }) public class extensionlistsumalltest { @test public void testdouble() { list<valuedouble> listdouble = new arraylist<>(); listdouble.add(new valuedouble(1, 1d)); listdouble.add(new valuedouble(2, 2d)); listdouble.add(new valuedouble(3, 3d)); double actual = listdouble.sumvaluesdouble("getvalue"); final double expected = 6d; assertequals(expected, actual); } @allargsconstructor @getter public class valuedouble { private final integer id; private final double value; } } what can make maven "see" method?
btw: use lot of extension methods in module c , maven has problem one. in project/eclipse use lombok long time , didn't had such problem before.
update:
i played little bit more , found out, when add 'dummy' code before execution of extension method maven compile code wihtout problems.
so, not compile
@slf4j @extensionmethod({ extensionlist.class }) public class smacalculator { static <c extends candle> double calculatesma(list<c> candles, int sma) { list<c> listtoworkon = preparelistforsmacalculation(candles, sma); double sum = listtoworkon.sumvaluesof("getcloseprice"); double smavalue = sum / sma; return smavalue; } ...other methods... } but compiles maven, , dupa object not referes listtoworkon object:
static <c extends candle> double calculatesma(list<c> candles, int sma) { list<c> listtoworkon = preparelistforsmacalculation(candles, sma); list<c> dupa = new arraylist<c>(); dupa.add(listtoworkon.first()); dupa.sumvaluesof("getcloseprice"); double sum = listtoworkon.sumvaluesof("getcloseprice"); double smavalue = sum / sma; return smavalue; }
i had same problem, after switching 1.16.2 , seems work.
Comments
Post a Comment