Skip to content
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

[native-image] Micronaut + Kafka fails to build native image with MethodHandle argument could not be reduced to at most a single call #1342

Closed
graemerocher opened this issue May 28, 2019 · 4 comments
Assignees

Comments

@graemerocher
Copy link
Member

I am attempting to get Micronaut + Kafka Client operational on Graal 19.

I have the following flags specified additional to the ones that are already working for Micronaut core:

Args = --initialize-at-build-time=org.apache.kafka,net.jpountz \
       --initialize-at-runtime=io.micronaut.configuration.kafka.embedded.KafkaEmbedded

However, the native image build fails when processing the Kafka client code. Is this a known issue?

You can find a sample at https://github.com/micronaut-graal-tests/micronaut-graal-experiments/tree/master/kaftest

Steps to reproduce the issue:

Do the following (because Sonatype OSS snapshots is currently down) to publish a local snapshot of Micronaut Kafka. Sorry about this step but Sonatype OSS snapshots repo is down currently:

  1. git clone https://github.com/micronaut-projects/micronaut-kafka.git
  2. ./gradlew pTML

Then checkout the sample application:

  1. git clone git@github.com:micronaut-graal-tests/micronaut-graal-experiments.git
  2. cd kaftest
  3. ./gradlew assemble
  4. native-image --no-server -cp build/libs/kaftest-0.1.jar

Error result:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call: java.lang.invoke.LambdaForm$MH.87134021.invoke_MT(Object, Object, Object)
Trace: 
	at parsing org.apache.kafka.common.record.CompressionType$5.wrapForOutput(CompressionType.java:122)
Call path from entry point to org.apache.kafka.common.record.CompressionType$5.wrapForOutput(ByteBufferOutputStream, byte): 
	at org.apache.kafka.common.record.CompressionType$5.wrapForOutput(CompressionType.java:122)
	at org.apache.kafka.common.record.MemoryRecordsBuilder.<init>(MemoryRecordsBuilder.java:130)
	at org.apache.kafka.common.record.MemoryRecordsBuilder.<init>(MemoryRecordsBuilder.java:166)
	at org.apache.kafka.common.record.MemoryRecords.builder(MemoryRecords.java:534)
	at org.apache.kafka.common.record.MemoryRecords.builder(MemoryRecords.java:516)
	at org.apache.kafka.common.record.MemoryRecords.builder(MemoryRecords.java:451)
	at org.apache.kafka.common.record.RecordsUtil.convertRecordBatch(RecordsUtil.java:110)
	at org.apache.kafka.common.record.RecordsUtil.downConvert(RecordsUtil.java:88)

@graemerocher
Copy link
Member Author

Sonatype OSS snapshots is working again so you can skip the first steps of cloning micronaut-kafka

@vmencik
Copy link

vmencik commented Jun 7, 2019

I have seen similar issue appear with Akka and GraalVM 19.0.0 even though it was not present in with the -rc GraalVM versions. I was able to get things working by initializing all classes at build time (--initialize-at-build-time) which I believe was the default behavior before the 19.0.0. release. See vmencik/akka-graal-native#3 for details.

@graemerocher
Copy link
Member Author

Managed to solve my issues with these substitutions https://github.com/micronaut-projects/micronaut-kafka/blob/master/kafka/src/main/java/io/micronaut/configuration/kafka/graal/KafkaSubstitutions.java

@ijuma
Copy link

ijuma commented Feb 14, 2021

FYI, the usage of method handles in this code was removed via apache/kafka#10123.

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

4 participants