yong-hu / objenesis

Automatically exported from code.google.com/p/objenesis
0 stars 0 forks source link

Add Dalvik VM support #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Objenesis should support Android's VM, Dalvik.

Instantiating objects in it can be done with the technique described here:
http://stackoverflow.com/questions/3121515/is-it-possible-to-bypass-constructors
-when-instantiating-objects-in-android
which in fact is already quite similar to what objenesis uses in other VMs.

I'm willing to try to implement it if you agree.

Thanks

Original issue reported on code.google.com by rdamazio@gmail.com on 1 Nov 2010 at 7:21

GoogleCodeExporter commented 9 years ago
We absolutely agree. If a patch is provided, it will be included in the next 
release.

Original comment by henri.tr...@gmail.com on 7 Nov 2010 at 2:53

GoogleCodeExporter commented 9 years ago

Original comment by henri.tr...@gmail.com on 7 Nov 2010 at 2:59

GoogleCodeExporter commented 9 years ago

Original comment by henri.tr...@gmail.com on 7 Nov 2010 at 2:59

GoogleCodeExporter commented 9 years ago
I'd have made a patch, but I think this deserves a look from someone who knows 
the objenesis code better, since it's very similar to
http://code.google.com/p/objenesis/source/browse/trunk/main/src/org/objenesis/in
stantiator/basic/ObjectInputStreamInstantiator.java
but I don't really understand what the serialized data put there does. It's 
also very similar to
http://code.google.com/p/objenesis/source/browse/trunk/main/src/org/objenesis/in
stantiator/basic/ObjectStreamClassInstantiator.java
but I don't see the newinstance method for that class in Android (it uses 
Harmony afaik).

Original comment by rdamazio@gmail.com on 7 Nov 2010 at 5:05

GoogleCodeExporter commented 9 years ago
I've just sent a handful of patches to objenesis-dev which should let Objenesis 
work on Ice Cream Sandwich and Jelly Bean, along with a wrapper for the TCK to 
let it run on Android devices or emulators. See 
https://groups.google.com/forum/?fromgroups=#!topic/objenesis-dev/I8J3fGGZvUQ .

Original comment by i...@google.com on 14 Dec 2012 at 5:15

GoogleCodeExporter commented 9 years ago

Original comment by henri.tr...@gmail.com on 8 Jan 2013 at 12:43

GoogleCodeExporter commented 9 years ago
Dalvik is now supported and a TCK was added. Many thanks to Ian Parkinson for 
his help.

Original comment by henri.tr...@gmail.com on 19 Jan 2013 at 12:54

GoogleCodeExporter commented 9 years ago
This now fails again on Android 4.2!  ObjectStreamClass.newInstance now takes a 
long instead of an int as its second argument!  Arg!

Original comment by cherry...@gmail.com on 4 Sep 2013 at 10:28

GoogleCodeExporter commented 9 years ago
I've confirmed that making a new instantiator strategy identical to the 
Android30Instantiator but using long as the 2nd argument to newInstance and 
long as the return type from getConstructorId works.  The VM version requiring 
this can be identified as 1.6.0.

Original comment by cherry...@gmail.com on 4 Sep 2013 at 11:10

GoogleCodeExporter commented 9 years ago
I can also confirm that adding an Android40Instantiator for version number 
1.6.0 with long type instead of integer works on Android 4.3

Original comment by tverb...@intec.ugent.be on 20 Sep 2013 at 1:57

Attachments:

GoogleCodeExporter commented 9 years ago
Hi, thank you very much for the feedback. I'm currently putting in place 
automated testing to easily verify every platforms. Right after I will deliver 
support for version 4.3.

Shouldn't be long.

Original comment by henri.tr...@gmail.com on 20 Sep 2013 at 2:18