Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objenesis can't work on the Google Apps Engine #12

Open
GoogleCodeExporter opened this issue Apr 10, 2015 · 10 comments
Open

Objenesis can't work on the Google Apps Engine #12

GoogleCodeExporter opened this issue Apr 10, 2015 · 10 comments

Comments

@GoogleCodeExporter
Copy link

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>(SunReflec
tionFactoryInstantiator.java:40)
at 
org.objenesis.strategy.StdInstantiatorStrategy.newInstantiatorOf(StdInstantiator
Strategy.java:85)
at org.objenesis.ObjenesisBase.getInstantiatorOf(ObjenesisBase.java:90)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)

Original issue reported on code.google.com by [email protected] on 9 Oct 2010 at 10:34

@GoogleCodeExporter
Copy link
Author

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.

Original comment by [email protected] on 7 Nov 2010 at 2:51

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 7 Nov 2010 at 2:58

  • Added labels: Milestone-1.3

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 7 Nov 2010 at 2:59

  • Added labels: Type-Enhancement

@GoogleCodeExporter
Copy link
Author

It also a problem for lamdaj

Original comment by [email protected] on 10 Aug 2011 at 6:10

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 23 Jan 2013 at 10:32

  • Added labels: Milestone-2.0
  • Removed labels: Milestone-1.3

@GoogleCodeExporter
Copy link
Author

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?

Original comment by [email protected] on 4 Apr 2013 at 8:49

@GoogleCodeExporter
Copy link
Author

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.

Original comment by [email protected] on 4 Apr 2013 at 10:55

@GoogleCodeExporter
Copy link
Author

(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,jav
a.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.

Original comment by [email protected] on 16 Apr 2013 at 10:17

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 21 Aug 2013 at 9:01

  • Removed labels: Milestone-2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant