-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom lookup for reflective schemas
This commit updates `BeanTableSchema` and `ImmutableTableSchema` to allow customers to provide their own instance of `MethodHandle.Lookup`. This is a necessary feature for situations where either of these schemas are used in an application where the item classes and the SDK classes are loaded by different classloaders. Since these schemas work by reflectively scanning the item class to find the attributes' getters and setters (or builder for immutable classes), the enhanced client makes use of a LambdaMetaFactory to construct lambdas that directly call these methods to avoid reflection when mapping to and from a `AttributeValue`s. At least as of Java 21, the way that lambdas are constructed (all lambdas, not just the ones created by the enhanced client), is they are made internal classes of the "caller" class, i.e. the class that defined it. The calling class is identified by the class that created the `Lookup` object. This means that when using the default `Lookup` created `LambdaToMethodBridgeBuilder`, all of these lambdas are inner classes of of `LambdaToMethodBridgeBuilder`. This is an issue when the item class is from a different classloader (or module) because when the lambda attempts to reference the item class (e.g. to call a getter), it's `ClassLoader` will throw a `ClassNotFoundException` because because it's not a class that it knows about. By allowing the customer to provide a `Lookup` object, they can guarantee that the the `Lookup` has visibility and access to the item classes.
- Loading branch information
Showing
15 changed files
with
725 additions
and
73 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.changes/next-release/feature-DynamoDBEnhancedClient-f39cb99.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "feature", | ||
"category": "DynamoDB Enhanced Client", | ||
"contributor": "", | ||
"description": "Add ability to provide a custom `MethodHandles.Lookup` object when using either `BeanTableSchema` or `ImmutableTableSchema`. By setting a custom `MethodHandles.Lookup` it allows these schemas to be used in applications where the item class and the SDK are loaded by different `ClassLoader`s." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.