Hi objenesis-dev,
I've been trying to get Objenesis running on Android/Dalvik; attached are some patches which I think makes it work at least on recent releases of Android. You've a bug for this in your bug tracker (
http://code.google.com/p/objenesis/issues/detail?id=13) which I'll update too.
I'd like to include Objenesis itself in the Android Open Source Project, for which we need to build from source. As things stand, the explicit references to sun.reflect.ReflectionFactory fail to build in the Android environment (and, I assume, would cause Objenesis's build to fail if using anything other than Sun's JDK?) I've also attached a patch which will fix this for me, and I'd be grateful if you could review it.
The attached patches are:
buildOnNonSun.diff - changes the SunReflectionFactory instantiators to use reflection, like all of the other instantiators, so that it can build in environments which don't have sun.reflect.ReflectionFactory.
androidInstantiator.diff - adds support for Android/Dalvik.
tckOnAndroid.diff - a little Android app which wraps the TCK so that it can be run on Android devices or emulators.
readme.diff - readme for the TCK app. There are no other readmes in the project, so I'm not sure if you'd rather have this sort of information on the project website?
It won't surprise you to know that the technique I've used in the two Android Instantiators is unsupported; like all the others it relies on internal methods which are subject to change. Using the TCK I've verified that it works on Android 4.0 and 4.1 (Ice Cream Sandwich and Jelly Bean; API levels 14 through 17). It doesn't work on Android 2.3 (Gingerbread; tested at API level 10). I haven't been able to test it on Android 3.0 (Honeycomb).
Many thanks for your help,
Ian Parkinson
--
Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902