yong-hu / objenesis

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

Support Apache Harmony #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by c...@protocol7.com on 29 Jul 2010 at 9:51

GoogleCodeExporter commented 9 years ago
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.

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
Harmony has a class ObjectAccessor that can be used:
http://svn.xstream.codehaus.org/browse/xstream/trunk/xstream/src/java/com/though
tworks/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.

Original comment by joerg.sc...@gmx.de on 7 Nov 2010 at 5:02

GoogleCodeExporter commented 9 years ago
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.

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

GoogleCodeExporter commented 9 years ago
Since Apache Harmony is now retired, there's no need to support it as of now

Original comment by henri.tr...@gmail.com on 30 Sep 2012 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by henri.tr...@gmail.com on 14 Aug 2013 at 11:47