Given that the following snippet works:
List<Integer> testCollection = new ArrayList<Integer>(Arrays.asList(new Integer[] { 1, 2, 3, 4 , 5, 6 }));
int result1 = max(testCollection, on(Integer.class).intValue());
int result2 = sum(testCollection, on(Integer.class).intValue());
I would expect those to also work, the same way:
List<Integer> testCollection = new ArrayList<Integer>(Arrays.asList(new Integer[] { 1, 2, 3, 4 , 5, 6 }));
int result1 = maxFrom(testCollection).intValue();
int result2 = sumFrom(testCollection).intValue();
But the later raise VerifyError on Android, more precisely when tryng to access
some net.sf.cglib.proxy.Enhancer class.
Ljava/lang/reflect/InvocationTargetException;:
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by:
Ljava/lang/VerifyError;: net.sf.cglib.proxy.Enhancer
at ch.lambdaj.proxy.ProxyUtil.createEnhancer(ProxyUtil.java:89)
at ch.lambdaj.proxy.ProxyUtil.createProxy(ProxyUtil.java:49)
at ch.lambdaj.proxy.ProxyUtil.createIterableProxy(ProxyUtil.java:76)
at ch.lambdaj.function.aggregate.ProxyAggregator.createProxyAggregator(ProxyAggregator.java:49)
at ch.lambdaj.Lambda.aggregateFrom(Lambda.java:573)
at ch.lambdaj.Lambda.aggregateFrom(Lambda.java:556)
at ch.lambdaj.Lambda.maxFrom(Lambda.java:856)
at com.bt.kraken.app.ui.AuthActivity.onCreate(AuthActivity.java:78)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
--------------------------------------------------------------------------------
------------
Aditional Information
- Verified in ambdaj-2.4-with-dependencies.jar
- Especific for Android Platform
- Android DX Tool issues the following warnings for several cglib classes
[2012-05-10 03:00:49 - Kraken Application] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(net.sf.cglib.util.StringSwitcher$Generator$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
--------------------------------------------------------------------------------
------------
Submitter Insight
Meanwhile, the library is still fully functional and (I guess) its a better
option to go for the little more verbose version of the sum/max calls for they
might be faster. It would be great to have a smaller version of this library
aim at Android specifically. This should save some precious kbytes from the
final APK and, if there`s no workaround for this issue, save a lot of time from
developers all around.
Back on the issue at hand, this might be caused by a dependency error on some
API not included on Android standard J5SE API mirror. I will try and download
the lambdaj source and drop it on a standard Android project on Eclipse to see
how it fares. Any leads on a possible issue will be apreciated.
Thanks in advance for your great work. I`ll keep you posted on any progress at
my side...
Original issue reported on code.google.com by bruno.vinicius.ds@gmail.com on 10 May 2012 at 6:33
Original issue reported on code.google.com by
bruno.vinicius.ds@gmail.com
on 10 May 2012 at 6:33