Issue 12 in objenesis: Objenesis can't work on the Google Apps Engine

43 views
Skip to first unread message

obje...@googlecode.com

unread,
Oct 9, 2010, 6:34:59 AM10/9/10
to objene...@googlegroups.com
Status: New
Owner: ----

New issue 12 by mario.fusco: Objenesis can't work on the Google Apps Engine
http://code.google.com/p/objenesis/issues/detail?id=12

Trying to use objenesis on GAE the following exception is thrown

java.lang.NoClassDefFoundError: sun.reflect.ReflectionFactory is a
restricted class.
Please see the Google App Engine developer's guide for more details.
at
com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
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)


obje...@googlecode.com

unread,
Nov 7, 2010, 9:54:11 AM11/7/10
to objene...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 12 by henri.tremblay: Objenesis can't work on the

Objenesis is indeed using some restricted classes. I'm not sure we can
workaround it.

Some insider information (from Google App Engine team) would be really
helpful

Anyhow, we'll look into it.


obje...@googlecode.com

unread,
Nov 7, 2010, 10:06:18 AM11/7/10
to objene...@googlegroups.com
Updates:
Labels: Milestone-1.3

Comment #2 on issue 12 by henri.tremblay: Objenesis can't work on the

(No comment was entered for this change.)

obje...@googlecode.com

unread,
Aug 10, 2011, 2:11:23 PM8/10/11
to objene...@googlegroups.com

Comment #4 on issue 12 by grego...@gmail.com: Objenesis can't work on the

It also a problem for lamdaj

obje...@googlecode.com

unread,
Jan 23, 2013, 5:32:09 PM1/23/13
to objene...@googlegroups.com
Updates:
Labels: -Milestone-1.3 Milestone-2.0

Comment #5 on issue 12 by henri.tr...@gmail.com: Objenesis can't work on

obje...@googlecode.com

unread,
Apr 4, 2013, 4:49:43 PM4/4/13
to objene...@googlegroups.com

Comment #6 on issue 12 by xyb...@gmail.com: Objenesis can't work on the
Was there any chance on making Objenesis work with GAE? If we implement our
own version of sun.reflect.ReflectionFactory, would be a work-around?

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

obje...@googlecode.com

unread,
Apr 4, 2013, 6:56:09 PM4/4/13
to objene...@googlegroups.com

Comment #7 on issue 12 by henri.tr...@gmail.com: Objenesis can't work on
I would of course be interested. Can someone try Unsafe.allocateInstance? I
will as soon as I have the time but I can't say when.

Then, if someone has an answer, I'm listening.

obje...@googlecode.com

unread,
Apr 16, 2013, 6:18:03 AM4/16/13
to objene...@googlegroups.com

Comment #8 on issue 12 by i...@google.com: Objenesis can't work on the
(Disclaimer: I'm a Googler, but I have no particular insider knowledge of
App Engine)


I had a bit of time, so I tried Unsafe.allocateInstance in a simple
AppEngine app - it fails with an Exception similar to the above:

Unsafe.allocateInstance(TestAllocateInstance.class):
java.lang.NoClassDefFoundError: sun.misc.Unsafe is a restricted class.
Please see the Google App Engine developer's guide for more details.
at
com.google.apphosting.runtime.security.shared.stub.sun.misc.Unsafe.<clinit>(Unsafe.java)


I also tried the ObjectStreamClass.newInstance() method that Objenesis can
use; this fails when tweaking the accessibility of the method:

java.lang.SecurityException: java.lang.IllegalAccessException: Reflection
is not allowed on java.lang.Object java.io.ObjectStreamClass.newInstance()
throws
java.lang.InstantiationException,java.lang.reflect.InvocationTargetException,java.lang.UnsupportedOperationException
at
com.google.appengine.runtime.Request.process-4e7d974abb397f1b(Request.java)
at java.lang.reflect.Method.setAccessible(Method.java:135)

Interestingly, this latter approach works fine in the dev appserver but
fails when running in the production App Engine environment.

As I understand it, it'd probably be considered a failure of App Engine's
sandbox for these sorts of techniques to work.

obje...@googlecode.com

unread,
Aug 3, 2013, 9:08:39 AM8/3/13
to objene...@googlegroups.com

Comment #9 on issue 12 by thinlen2...@gmail.com: Objenesis can't work on
reflections.0.9.9-RC1.jar (https://code.google.com/p/reflections/)
working well in my google app engine project.
But I don't use it directly, I don't know if it can replace
sun.reflect.ReflectionFactory.
Hope the jar have any help to the issue.

obje...@googlecode.com

unread,
Aug 21, 2013, 5:02:40 PM8/21/13
to objene...@googlegroups.com
Updates:
Labels: -Milestone-2.0

Comment #10 on issue 12 by henri.tr...@gmail.com: Objenesis can't work on
(No comment was entered for this change.)

Reply all
Reply to author
Forward
0 new messages