New issue 11 by nik...@protocol7.com: Support Apache Harmony
http://code.google.com/p/objenesis/issues/detail?id=11
What steps will reproduce the problem?
1. Use Objenesis in Apache Harmony, e.g. using Easymock.
What is the expected output? What do you see instead?
Expect to be able to create mocks. Instead, the following stacktrace is
provided:
java.lang.NoClassDefFoundError: sun/reflect/ReflectionFactory
at
org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.<init>(SunReflectionFactoryInstantiator.java:40)
at
org.objenesis.strategy.StdInstantiatorStrategy.newInstantiatorOf(StdInstantiatorStrategy.java:85)
at org.objenesis.ObjenesisBase.getInstantiatorOf(ObjenesisBase.java:90)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
at org.objenesis.ObjenesisHelper.newInstance(ObjenesisHelper.java:43)
at
org.easymock.internal.ObjenesisClassInstantiator.newInstance(ObjenesisClassInstantiator.java:27)
at
org.easymock.internal.ClassProxyFactory.createProxy(ClassProxyFactory.java:233)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:60)
What version of the product are you using? On what operating system?
Objenesis 1.2
Harmony rev 713673
Easymock 3.0
Please provide any additional information below.
Looking at StdInstantiatorStrategy, using Harmony it would fall back on
SunReflectionFactoryInstantiator which will not be supported as Harmony
does not contain any com.sun classes.
Comment #1 on issue 11 by henri.tremblay: Support Apache Harmony
http://code.google.com/p/objenesis/issues/detail?id=11
We'll look into it. A specific implementation is required for Harmony. As
you said, the fallback doesn't work.
If someone could provide a patch for it, that would be of great help.
Comment #2 on issue 11 by henri.tremblay: Support Apache Harmony
http://code.google.com/p/objenesis/issues/detail?id=11
(No comment was entered for this change.)
Harmony has a class ObjectAccessor that can be used:
http://svn.xstream.codehaus.org/browse/xstream/trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/HarmonyReflectionProvider.java?r=HEAD
However, as stated, XStream fails to run all ~1000 unit tests, because at
some point the JVM gets corrupt. Hard to say if its caused by one of the
deserialized objects or only because of using this class.
Thought I'd mention that this should be looked at together with issue 13,
since Harmony is the library usually used on top of Dalvik.