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

New MagicInstantiator using MagicAccessorImpl #35

Closed
henri-tremblay opened this issue Jul 24, 2015 · 5 comments
Closed

New MagicInstantiator using MagicAccessorImpl #35

henri-tremblay opened this issue Jul 24, 2015 · 5 comments
Assignees
Milestone

Comments

@henri-tremblay
Copy link
Contributor

New issue created from issue #23 comment #23 (comment)

Synthesize the ObjectInstantiator instance, so it does what you attempted (manually invoking the desired constructor), and having it extend sun.reflect.MagicAccessorImpl, as its subclasses are not subject to the regular bytecode verification, and allow you to do it without globally disabling the verifier.

MagicAccessorImpl is package scope, however, its 'no verifier' property means you can create subclasses outside of the package.

You can find the prototype here. The interesting part is in the MagicInstantiatorStrategy class.

I am using ASM to generate the ObjectInstantiator instance. This is a relatively performance-heavy operation, but seeing as instantiator instances are cached by default, this should provide performance similar to the other instantiators.

@henri-tremblay
Copy link
Contributor Author

It's working perfectly. Sadly, MagicAccessorImpl isn't present on Google App Engine so this instantiator doesn't work either

@henri-tremblay henri-tremblay removed this from the 2.2 milestone Jul 25, 2015
@jcarvalho
Copy link

Perhaps there is another GAE-specific class that will trigger the same behavior?

I'm not sure if the code for the JVM running on GAE is open-source, if it is, it may not be so hard to find.

@henri-tremblay
Copy link
Contributor Author

From as far as I know, it's not available. We will need to have help from Google to find a solution.

@henri-tremblay
Copy link
Contributor Author

The magic instantiator is now merge into objenesis

@henri-tremblay henri-tremblay added this to the 2.2 milestone Jul 30, 2015
@henri-tremblay
Copy link
Contributor Author

@jcarvalho BTW, I don't know if you had a look at the final version. Instead of having a special strategy, I'm using delegation in the instantiator to create the magic one

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

2 participants