Skip to content

DynamoDB Enhanced Client UnsupportedFeatureException #3080

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
JouperCoding opened this issue Dec 18, 2020 · 1 comment
Closed

DynamoDB Enhanced Client UnsupportedFeatureException #3080

JouperCoding opened this issue Dec 18, 2020 · 1 comment
Assignees

Comments

@JouperCoding
Copy link

Describe the issue
When using https://github.com/aws/aws-sdk-java-v2/tree/master/services-custom/dynamodb-enhanced and creating my DynamoDbBean tables. The following issue occurs.

Steps to reproduce the issue
In any class constructor, create a DynamoDBEnhancedClient and create the dbt table.

this.client = DynamoDbEnhancedClient.create()
this.dbtMyTable = client.table("MyTable", TableSchema.fromBean(MyTable.class));

This will cause the native-image (fallback image) .exe to fail and when launching it, the following exception will occur.

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:330)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.createStaticTableSchema(BeanTableSchema.java:167)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:124)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.create(BeanTableSchema.java:116)
        at software.amazon.awssdk.enhanced.dynamodb.TableSchema.fromBean(TableSchema.java:80)
        at yggdrasil.api.services.SecurityService.<init>(SecurityService.java:57)
        at yggdrasil.api.services.$SecurityServiceDefinition.build(Unknown Source)
        at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1898)
        ... 26 common frames omitted
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: MethodHandleNatives.init()
        at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
        at java.lang.invoke.MethodHandleNatives.init(MethodHandleNatives.java:59)
        at java.lang.invoke.MemberName.<init>(MemberName.java:668)
        at java.lang.invoke.MethodHandles$Lookup.unreflectConstructor(MethodHandles.java:1826)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.lambda$null$2(LambdaToMethodBridgeBuilder.java:80)
        at software.amazon.awssdk.utils.FunctionalUtils.lambda$safeSupplier$4(FunctionalUtils.java:108)
        at software.amazon.awssdk.utils.FunctionalUtils.invokeSafely(FunctionalUtils.java:136)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.lambda$build$3(LambdaToMethodBridgeBuilder.java:80)
        at java.util.Optional.map(Optional.java:265)
        at software.amazon.awssdk.utils.Either.lambda$map$0(Either.java:51)
        at java.util.Optional.orElseGet(Optional.java:369)
        at software.amazon.awssdk.utils.Either.map(Either.java:51)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:78)
        ... 35 common frames omitted

However, by changing the code by creating them as members directly, something like this

	static final private DynamoDbEnhancedClient client = DynamoDbEnhancedClient.create();
	static final private DynamoDbTable<MyTable> dbtRegisterTable = client.table("MyTable", TableSchema.fromBean(MyTable.class));

The native-image .exe will atleast start as a fallback image. However, during the native-image analysis

[my-app:10036]     analysis:  62,830.88 ms,  5.63 GB
Warning: Aborting stand-alone image build. Unsupported features in 7 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call or single field access. The method handle must be a compile time constant, e.g., be loaded from a `static final` field. Method that contains the method handle invocation: java.lang.invoke.MethodHandle.invokeBasic()
To enable method handles that do not require LambdaForm interpretation (e.g. because of a call to MethodHandle.bindTo()) or to diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The error is then reported at run time when the invoke is executed and the method handle has to be interpreted.
Trace:
        at parsing java.lang.invoke.Invokers$Holder.invoke_MT(Invokers$Holder)
Call path from entry point to java.lang.invoke.Invokers$Holder.invoke_MT(Object, Object):
        at java.lang.invoke.Invokers$Holder.invoke_MT(Invokers$Holder)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:90)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ObjectConstructor.create(ObjectConstructor.java:37)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:330)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.lambda$createAttributeConverterFromAnnotation$2(BeanTableSchema.java:277)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema$$Lambda$2679/0x00000007c2156040.apply(Unknown Source)
        at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:330)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported method java.lang.invoke.MethodHandleNatives.clearCallSiteContext(MethodHandleNatives$CallSiteContext) is reachable
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
        at parsing java.lang.invoke.MethodHandleNatives$CallSiteContext.run(MethodHandleNatives.java:92)
Call path from entry point to java.lang.invoke.MethodHandleNatives$CallSiteContext.run():
        at java.lang.invoke.MethodHandleNatives$CallSiteContext.run(MethodHandleNatives.java:92)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
        at com.oracle.svm.core.code.IsolateEnterStub.WindowsJavaThreads_osThreadStartRoutine_4bc03aa26f8cdfc97ebd54050e8ae4bce1023851(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
        at parsing java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:1102)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findStatic(Class, String, MethodType):
        at java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:1102)
        at java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:200)
        at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:329)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:83)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ObjectConstructor.create(ObjectConstructor.java:37)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:330)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.lambda$createAttributeConverterFromAnnotation$2(BeanTableSchema.java:277)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema$$Lambda$2679/0x00000007c2156040.apply(Unknown Source)
        at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:330)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
        at parsing java.lang.invoke.MethodHandles$Lookup.findStaticGetter(MethodHandles.java:1539)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findStaticGetter(Class, String, Class):
        at java.lang.invoke.MethodHandles$Lookup.findStaticGetter(MethodHandles.java:1539)
        at java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:199)
        at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:329)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:83)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ObjectConstructor.create(ObjectConstructor.java:37)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:330)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.lambda$createAttributeConverterFromAnnotation$2(BeanTableSchema.java:277)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema$$Lambda$2679/0x00000007c2156040.apply(Unknown Source)
        at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:330)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
        at parsing java.lang.invoke.MethodHandles$Lookup.revealDirect(MethodHandles.java:1983)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.revealDirect(MethodHandle):
        at java.lang.invoke.MethodHandles$Lookup.revealDirect(MethodHandles.java:1983)
        at java.lang.invoke.AbstractValidatingLambdaMetafactory.<init>(AbstractValidatingLambdaMetafactory.java:133)
        at java.lang.invoke.InnerClassLambdaMetafactory.<init>(InnerClassLambdaMetafactory.java:158)
        at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:324)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.build(LambdaToMethodBridgeBuilder.java:83)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.ObjectConstructor.create(ObjectConstructor.java:37)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.newObjectSupplierForClass(BeanTableSchema.java:330)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema.lambda$createAttributeConverterFromAnnotation$2(BeanTableSchema.java:277)
        at software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema$$Lambda$2679/0x00000007c2156040.apply(Unknown Source)
        at sun.security.ec.XECParameters$1.get(XECParameters.java:183)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:330)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
        at parsing java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:1740)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.unreflect(Method):
        at java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:1732)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.lambda$null$0(LambdaToMethodBridgeBuilder.java:79)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder$$Lambda$2711/0x00000007c1cac840.get(Unknown Source)
        at software.amazon.awssdk.utils.FunctionalUtils.lambda$safeSupplier$4(FunctionalUtils.java:108)
        at software.amazon.awssdk.utils.FunctionalUtils$$Lambda$2288/0x00000007c2259c40.get(Unknown Source)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:330)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)
Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported type java.lang.invoke.MemberName is reachable: All methods from java.lang.invoke should have been replaced during image building.
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Trace:
        at parsing java.lang.invoke.MethodHandles$Lookup.unreflectConstructor(MethodHandles.java:1826)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.unreflectConstructor(Constructor):
        at java.lang.invoke.MethodHandles$Lookup.unreflectConstructor(MethodHandles.java:1826)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder.lambda$null$2(LambdaToMethodBridgeBuilder.java:80)
        at software.amazon.awssdk.enhanced.dynamodb.internal.mapper.LambdaToMethodBridgeBuilder$$Lambda$2710/0x00000007c1d36840.get(Unknown Source)
        at software.amazon.awssdk.utils.FunctionalUtils.lambda$safeSupplier$4(FunctionalUtils.java:108)
        at software.amazon.awssdk.utils.FunctionalUtils$$Lambda$2288/0x00000007c2259c40.get(Unknown Source)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:190)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:143)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:330)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

Describe GraalVM and your environment:
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.9 (GraalVM Community 11.0.9+10-jvmci-20.3-b06)
OS: Windows 10 10.0 amd64

@munishchouhan
Copy link
Contributor

@JouperCoding from the error, I can see the issue is related to Method Handle, which is not supported by native-image currently. you can follow issue #2761 to see progress on Method handle support

@munishchouhan munishchouhan self-assigned this Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants