Skip to content

DATACMNS-578 - PoC: Speed up instance creation by generating Factory classes with ASM. #98

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

Closed
wants to merge 6 commits into from

Conversation

thomasdarimont
Copy link

PROOF-OF-CONCEPT please do not merge yet!

Introduced BytecodeGeneratingEntityInstantiator which dynamically generates classes to speed up the dynamic instantiation of objects. Since we cannot support every use case with byte code generation we gracefully fallback to the ReflectiveEntityInstantiator.

Thomas Darimont added 2 commits October 13, 2014 16:34
…es with ASM.

Introduced BytecodeGeneratingEntityInstantiator which dynamically generates classes to speed up the dynamic instantiation of objects. Since we cannot support every use case with byte code generation we gracefully fallback to the ReflectiveEntityInstantiator.

Original pull request: #98.
}

@SuppressWarnings("unchecked")
private <T> Constructor<T> findAppropriateConstructorForArguments(Class<T> clazz, Object[] args) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that really needed? If no PreferredConstructor is found we either deal with the case that there are only constructors available that take arguments but none of them has been annotated with @PersistenceConstructor. This is usually the case if a special converter is registered for that type so that we're never going to instantiate it anyway.

The other aspect is that the non-availability of a preferred constructor results in the argument array being empty so that we can only fallback to instantiating the implicit default constructor anyway. This is very likely to fail (except array instantiations) as the default constructor would've been detected during preferred constructor detection in the first place.

Thomas Darimont added 4 commits October 17, 2014 15:24
…es with ASM.

Cleaned up byte code generation and removed usage of JDK 8 specific types.
…es with ASM.

Added support for unboxing of constructor parameters and more robust handling for cases where we cannot generate a custom ObjectInstantiator. In such cases we'll fall back to the ReflectiveEntityInstantiator.
…es with ASM.

Removed book-keeping and logging for types which we cannot generate byte code for.
…es with ASM.

Refactoring according to code review.
@odrotbohm odrotbohm closed this Oct 21, 2014
@odrotbohm odrotbohm deleted the issue/DATACMNS-578 branch October 21, 2014 10:19
thomasdarimont pushed a commit that referenced this pull request Oct 21, 2014
…es with ASM.

Introduced BytecodeGeneratingEntityInstantiator which dynamically generates classes to speed up the dynamic instantiation of objects. Since we cannot support every use case with byte code generation we gracefully fallback to the ReflectiveEntityInstantiator.

BytecodeGeneratingEntityInstantiator has support for unboxing of constructor parameters and more robust handling for cases where we cannot generate a custom ObjectInstantiator.

Original pull request: #98.
odrotbohm added a commit that referenced this pull request Oct 21, 2014
Added some JavaDoc where missing. Better variable names and slightly parameter ordering changes. Formatting in the unit tests and reference to the original ticket.

Original pull request: #98.
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

Successfully merging this pull request may close these issues.

2 participants