Skip to content

Invoke with MethodHandle argument could not be reduced to at most a single call: java.lang.invoke.MethodHandleImpl.buildVarargsArray(MethodHandle, MethodHandle, int) #1376

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
rmannibucau opened this issue Jun 13, 2019 · 3 comments
Assignees

Comments

@rmannibucau
Copy link

Trying to compile natively Apache Meecrowave (https://openwebbeans.apache.org/meecrowave/) I get this weird error:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Invoke with MethodHandle argument could not be reduced to at most a single call: 
java.lang.invoke.MethodHandleImpl.buildVarargsArray(MethodHandle, MethodHandle, int)
Trace: 
at parsing java.lang.invoke.MethodHandleImpl.varargsArray(MethodHandleImpl.java:1634)

Call path from entry point to java.lang.invoke.MethodHandleImpl.varargsArray(Class, int):
at java.lang.invoke.MethodHandleImpl.varargsArray(MethodHandleImpl.java:1611)
at java.lang.invoke.MethodHandle.asCollector(MethodHandle.java:999)
at java.lang.invoke.MethodHandleImpl$AsVarargsCollector.(MethodHandleImpl.java:460)
at java.lang.invoke.MethodHandleImpl$AsVarargsCollector.(MethodHandleImpl.java:454)
at java.lang.invoke.MethodHandleImpl.makeVarargsCollector(MethodHandleImpl.java:445)
at java.lang.invoke.MethodHandle.setVarargs(MethodHandle.java:1325)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1670)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:1605)
at java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:781)
at java.lang.invoke.BoundMethodHandle$Factory.makeCbmhCtor(BoundMethodHandle.java:818)
at java.lang.invoke.BoundMethodHandle$Factory.makeCtors(BoundMethodHandle.java:763)
at java.lang.invoke.BoundMethodHandle$SpeciesData.(BoundMethodHandle.java:349)
at java.lang.invoke.BoundMethodHandle$SpeciesData$1.apply(BoundMethodHandle.java:389)
at java.lang.invoke.BoundMethodHandle$SpeciesData$1.apply(BoundMethodHandle.java:383)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.WeakHashMap$KeySpliterator.forEachRemaining(WeakHashMap.java:1137)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at org.apache.meecrowave.Meecrowave.close(Meecrowave.java:995)
at org.apache.meecrowave.runner.Cli.run(Cli.java:98)
at org.apache.meecrowave.runner.Cli.main(Cli.java:120)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:153)

I'm using this command:

native-image \
  -cp "$classpath" \
  --static \
  --verbose \
  --language:llvm \
  --allow-incomplete-classpath \
  --report-unsupported-elements-at-runtime \
  --initialize-at-build-time=org.apache.webbeans.annotation.EmptyAnnotationLiteral \
  org.apache.meecrowave.runner.Cli

And classpath contains:

commons-cli-1.4.jar:cxf-core-3.3.2.jar:cxf-integration-cdi-3.3.2.jar:cxf-rt-frontend-jaxrs-3.3.2.jar:cxf-rt-rs-client-3.3.2.jar:cxf-rt-security-3.3.2.jar:cxf-rt-transports-http-3.3.2.jar:geronimo-config-impl-1.2.2.jar:geronimo-jcache_1.0_spec-1.0-alpha-1.jar:geronimo-jcache-simple-1.0.2.jar:geronimo-opentracing-1.0.2.jar:geronimo-opentracing-common-1.0.2.jar:johnzon-core-1.1.12.jar:johnzon-jaxrs-1.1.12.jar:johnzon-jsonb-1.1.12.jar:johnzon-mapper-1.1.12.jar:log4j-api-2.11.2.jar:log4j-core-2.11.2.jar:log4j-jul-2.11.2.jar:log4j-slf4j-impl-2.11.2.jar:log4j-web-2.11.2.jar:meecrowave-core-1.2.8.jar:meecrowave-junit-1.2.8.jar:meecrowave-specs-api-1.2.8.jar:microprofile-config-api-1.3.jar:microprofile-opentracing-api-1.2.1.jar:opentracing-api-0.31.0.jar:openwebbeans-el22-2.0.11.jar:openwebbeans-impl-2.0.11.jar:openwebbeans-spi-2.0.11.jar:openwebbeans-web-2.0.11.jar:slf4j-api-1.7.26.jar:tomcat-api-9.0.21.jar:tomcat-catalina-9.0.21.jar:tomcat-coyote-9.0.21.jar:tomcat-jaspic-api-9.0.21.jar:tomcat-jni-9.0.21.jar:tomcat-juli-9.0.21.jar:tomcat-servlet-api-9.0.21.jar:tomcat-util-9.0.21.jar:tomcat-util-scan-9.0.21.jar:xbean-asm7-shaded-4.13.jar:xbean-finder-shaded-4.13.jar:xbean-reflect-4.13.jar

The line 995 is:

Stream.of("catalina.base", "catalina.home").forEach(System::clearProperty);

Indeed it can be rewritten but I think it should be supported since it is quite simple and more and more commong to see that kind of pattern in apps.

@cstancu cstancu self-assigned this Jun 14, 2019
@cstancu
Copy link
Member

cstancu commented Jun 14, 2019

See #1036 (comment) for an explanation for this error.

@rmannibucau
Copy link
Author

I understand the source but it hits almost any java 8 lib. CXF also has this issue even if code is still mainly using java 6 style and just starts using j8 for instance.

About reporting the error at runtime: not sure it is an issue, all the cases I hit - for now indeed - were statically identifiable from sources.

In other words I suspect that if javac looses some meta, graal javac should be able to add it in a methodhandle.json or so or worse case let the user/agent define it maybe.

Also note that using the previous bytecode graal is able to determine what to call since it makes the methodhandle contextual and fully determined - at least in several cases.

So long story short, graal can still do better IMHO ;).

@cstancu
Copy link
Member

cstancu commented Apr 29, 2020

MethodHandle support discussion is at #955.

@cstancu cstancu closed this as completed Apr 29, 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