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

Clone Weaving #2

Open
vjkoskela opened this issue Dec 23, 2015 · 2 comments
Open

Clone Weaving #2

vjkoskela opened this issue Dec 23, 2015 · 2 comments

Comments

@vjkoskela
Copy link
Member

The current clone functionality in OvalBuilder is implemented with Java reflection. Consequently, it is extremely slow and can significantly degrade application performance if invoked frequently. The clone should be rewritten using code weaving. This will be the least disruptive to existing use cases.

Alternatives that were considered included implementing Serializable or using another serialization library (e.g. Jackson). These would require changes to classes being cloned.

The base OvalBuilder should have a public clone method with that throws a OperationNotSupportedException (or some such). The weaver will find subclasses of OvalBuilder and override the method with generated code. Essentially this is copy-constructor generation through a builder.

The existing clone(instance, builder) contract can be expressed with a call to clone builder.clone(instance). The other variant of clone, namely clone(instance), will still need to reflectively instantiate the builder and should be marked deprecated.

@vjkoskela
Copy link
Member Author

The cloning functionality has been upgraded to use caching of the builder constructor and getter-setter pairs between the type and builder. This has significantly improved performance (~30x). It would likely still be faster to weave the clone functionality. However, the priority of this enhancement has been decreased significantly.

@vjkoskela
Copy link
Member Author

See #18 for how we could use javassist to inject the byte code for this instead of relying on reflection.

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

No branches or pull requests

1 participant