-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Failed to generate method handle for GraalVM 21.1.0 for dynamodb-enhanced client #3386
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
Comments
I have this problem with 20.0.0.2 as well
|
any updates? |
It seems I'm experiencing the same w/ 21.2. |
The code being used is using the lambda metafactory feature, which tries to define a new class at runtime, and that is currently not supported by Native Image. We are working to support this use case but it still requires some implementation work to be done. |
As workaround you can write a function which creates a
|
This issue persists with GraalVM version 21.3.0.r11 as well |
@Alex100 do you happen to have an example app demonstrating how your workaround is used? |
As a workaround, I've been able to use StaticTableSchema for mapping simple objects, but run into issues when mapping more complex attributes. For example, how would I map something like this using StaticTableSchema? Please note,
|
@loicottet Just wondering if you have an update on this? Is this something that is still going to be a number of months away? Thanks. |
@deandelponte I also run into trouble with that - had to look into You need a schema for each "document" class, regardless if it's table-level entity or nested one: private val addressGeoLocationSchema by lazy {
TableSchema.builder(Address.GeoLocation::class.java)
.newItemSupplier { Address.GeoLocation() }
.addAttribute(Double::class.java) {
it
.name("latitude")
.getter(Address.GeoLocation::latitude::get)
.setter(Address.GeoLocation::latitude::set)
}
.addAttribute(Double::class.java) {
it
.name("longitude")
.getter(Address.GeoLocation::longitude::get)
.setter(Address.GeoLocation::longitude::set)
}
.addAttribute(Double::class.java) {
it
.name("altitude")
.getter(Address.GeoLocation::altitude::get)
.setter(Address.GeoLocation::altitude::set)
}
.build()
}
private val addressTableSchema by lazy {
// temporarily not possible for GraalVM - https://github.com/oracle/graal/issues/3386
//TableSchema.fromClass(Address::class.java)
TableSchema.builder(Address::class.java)
.newItemSupplier { Address() }
.addAttribute(EnhancedType.documentOf(Address.GeoLocation::class.java, addressGeoLocationSchema)) {
it
.name("geoLocation")
.getter(Address::geoLocation::get)
.setter(Address::geoLocation::set)
}
.build()
} |
Hello, I got the same limitation, tested this with GraalVM 22.2.0 (Windows) seems to be related to how this library is using java.awt. Started a discussion here to see if something can be done to improve the out of box experience. aws/aws-sdk-java-v2#3473 It may be possible to use @DynamoDbBean and @DynamoDbAttributes with TableSchema.fromClass() with proper NI configuration, but using java.awt may bloat the native-image unnecessarily. My setup is very similar to @Alex100 where we use the micronaut framework. See: #4659 which seems to be somewhat similar to this. |
Any progress on that? |
|
Thanks for the update! |
Hi Team @graemerocher is there any update on the above issue. |
Hi,
I'm trying to compile dynamodb-enhanced client with Graalvm 21.1(graalvm-ce-java11-21.1.0) and awssdk.version=2.16.50
Here the code:
DynamoDbTable<Book> dynamoDbTable = dynamoDbEnhancedClient.table(TABLE_NAME, TableSchema.fromBean(Book.class));
Reflection config doesn't help. I generated native-image artifacts with -agentlib: but it still doesn't help.
GraalVM 21.1 supports Method Handler, I hope it can be fixed.
https://github.com/aws/aws-sdk-java-v2/blob/master/services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/mapper/LambdaToMethodBridgeBuilder.java#L76
Error: Exception in thread "main" java.lang.ExceptionInInitializerError at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:315) Caused by: java.lang.IllegalArgumentException: Failed to generate method handle. at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:92) at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ObjectConstructor.create(ObjectConstructor.java:37) at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:361) at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.createStaticTableSchema(BeanTableSchema.java:172) at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:129) at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:121) at software.amazon.awssdk.enhanced.dynamodb.TableSchema.fromBean(TableSchema.java:81) at com.filichkin.blog.lambda.v3.handler.test.Main.initDispatcher(Main.java:39)
The text was updated successfully, but these errors were encountered: