Skip to content

DATACMNS-809 — Investigate use of method handles for property access #159

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 4 commits into from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Apr 14, 2016

We now support generated PersistentPropertyAccessors when using Java 7 and if property/association name hashCodes are unique within a PersistentEntity.
Generated PersistentPropertyAccessors provide optimized access to properties. They use either MethodHandles or direct property/field access, depending on the visibility/final modifiers of the entity type and its members. A generated PersistentPropertyAccessor is injected into the originating class loader of the entity class to enable optimizations for package-default/protected member access.

Open issues

  • Where to keep the root reference to ClassGeneratingPropertyAccessorFactory as creating factories per PersistentEntity might be expensive

Related ticket: DATACMNS-809

mp911de and others added 3 commits May 2, 2016 16:59
We now support generated PersistentPropertyAccessors when using Java 7 and if property/association name hashCodes are unique within a PersistentEntity.
Generated PersistentPropertyAccessors provide optimized access to properties. They use either MethodHandles or direct property/field access, depending on the visibility/final modifiers of the entity type and its members. A generated PersistentPropertyAccessor is injected into the originating class loader of the entity class to enable optimizations for package-default/protected member access.

Original pull request: #159.
Made as many methods in ClassGeneratingPropertyAccessorFactory static as possible. Some code formatting. Some warning suppressions where needed.

Original pull request: #159.
@odrotbohm odrotbohm force-pushed the issue/DATACMNS-809 branch from 29ef67e to 0ea98b3 Compare May 2, 2016 15:00
@odrotbohm odrotbohm changed the title DATACMNS-809 Investigate use of method handles for property access DATACMNS-809 — Investigate use of method handles for property access May 2, 2016
@odrotbohm
Copy link
Member

I've applied a round of polishing. Open todo as just discussed: move registration of PersistentPropertyAccessorFactory into AbstractMappingContext to avoid creating instances for every BasicPersistentEntity.

I tested the current state of implementation against the Spring Data examples and they seem to work fine also in combined usage with the Spring Boot development tools. I noticed that ClassGeneratingPropertyAccessorFactory.canGenerateAccessorClass(…) was called quite often (once per request for a PersistentPropertyAccessor but I guess that's gonna resolve with the refactoring suggested above, as the call to that method will be a one time effort at the time the PersistentEntity is created.

…tyAccessorFactory.

PersistentPropertyAccessorFactory can be set on a BasicPersistentEntity. This is done by AbstractMappingContext once the entity is verified. This change reduces the count of PersistentPropertyAccessorFactory instances and performs the isSupported check only once, when initializing the entity.

Original pull request: #159.
odrotbohm pushed a commit that referenced this pull request May 3, 2016
We now support generated PersistentPropertyAccessors when using Java 7 and if property/association name hashCodes are unique within a PersistentEntity.
Generated PersistentPropertyAccessors provide optimized access to properties. They use either MethodHandles or direct property/field access, depending on the visibility/final modifiers of the entity type and its members. A generated PersistentPropertyAccessor is injected into the originating class loader of the entity class to enable optimizations for package-default/protected member access.

Original pull request: #159.
odrotbohm added a commit that referenced this pull request May 3, 2016
Made as many methods in ClassGeneratingPropertyAccessorFactory static as possible. Some code formatting. Some warning suppressions where needed.

Original pull request: #159.
odrotbohm pushed a commit that referenced this pull request May 3, 2016
…tyAccessorFactory.

PersistentPropertyAccessorFactory can be set on a BasicPersistentEntity. This is done by AbstractMappingContext once the entity is verified. This change reduces the count of PersistentPropertyAccessorFactory instances and performs the isSupported check only once, when initializing the entity.

Original pull request: #159.
odrotbohm added a commit that referenced this pull request May 3, 2016
Removed DefaultPersistentPropertyAccessorFactory as it only delegates to the class generating one. Tweaked AbstractMappingContext to actually use the latter in the first place. Introduced BeanWrapperPropertyAccessorFactory to implement the default behavior of using a BeanWrapper and initialize BasicPersistentEntity to avoid a null clause in getPersistentPropertyAccessor(…).

Removed getPersistentPropertyAccessorFactory and rather rely on ReflectionTestUtils in tests to avoid additional API being exposed.

Original pull request: #159.
@odrotbohm odrotbohm closed this May 3, 2016
@odrotbohm odrotbohm deleted the issue/DATACMNS-809 branch May 3, 2016 14:48
Aloren pushed a commit to Aloren/spring-data-commons that referenced this pull request Jun 20, 2019
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