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

java.lang.ClassCastException: java.lang.invoke.BoundMethodHandle$Species_LL cannot be cast to java.lang.invoke.SimpleMethodHandle #3341

Closed
etspaceman opened this issue Apr 12, 2021 · 13 comments
Assignees

Comments

@etspaceman
Copy link

Describe the issue
Something seems to be missing from the MethodHandle support, getting:

Caused by: java.lang.ClassCastException: java.lang.invoke.BoundMethodHandle$Species_LL cannot be cast to java.lang.invoke.SimpleMethodHandle
	at com.oracle.svm.methodhandles.MethodHandleIntrinsic.execute(MethodHandleIntrinsic.java:254)
	at java.lang.invoke.MethodHandle.invokeBasic(MethodHandle.java:80)
	at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(LambdaForm.java:74)
	at java.lang.invoke.LambdaForm.interpretName(LambdaForm.java:981)
	at java.lang.invoke.LambdaForm.interpretWithArguments(LambdaForm.java:958)
	at java.lang.invoke.MethodHandle.invokeBasic(MethodHandle.java:171)
	at java.lang.invoke.MethodHandle.invokeBasic(MethodHandle.java:0)
	at java.lang.invoke.LambdaForm$MH/1417001346.invokeExact_MT(LambdaForm$MH)
	at org.apache.lucene.store.MMapDirectory.lambda$null$0(MMapDirectory.java:404)
	at java.security.AccessController.doPrivileged(AccessController.java:84)
	at org.apache.lucene.store.MMapDirectory.lambda$newBufferCleaner$1(MMapDirectory.java:402)
	... 47 more

Creating based on :

#2761 (comment)

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. Clone https://github.com/etspaceman/kinesis-mock/tree/4acc3ee60a6dda9ea85629c2551a25faa9985ac6
  2. Run sbt dockerComposeUp

Describe GraalVM and your environment:

  • Using image ghcr.io/graalvm/graalvm-ce:java11-21.0.0.2

message.txt

@munishchouhan
Copy link
Contributor

@etspaceman thanks for the issue
we will check it out and get back to you

@munishchouhan munishchouhan self-assigned this Apr 16, 2021
@dainiusjocas
Copy link

I have the same issue.

@munishchouhan
Copy link
Contributor

@etspaceman when I tried your reproducer, I didn't get any error:

docker run ghcr.io/etspaceman/kinesis-mock:0.0.5-SNAPSHOT
[ioapp-compute-1] INFO  k.m.KinesisMockService contextId=c39ba88d-a8d1-11eb-87b3-176e2a535263, cacheConfig={"awsAccountId":"000000000000","awsRegion":"us-east-1","createStreamDuration":"500 milliseconds","deleteStreamDuration":"500 milliseconds","deregisterStreamConsumerDuration":"500 milliseconds","mergeShardsDuration":"500 milliseconds","registerStreamConsumerDuration":"500 milliseconds","shardLimit":50,"splitShardDuration":"500 milliseconds","startStreamEncryptionDuration":"500 milliseconds","stopStreamEncryptionDuration":"500 milliseconds","updateShardCountDuration":"500 milliseconds"} - Logging Cache Config 
[ioapp-compute-2] INFO  k.m.KinesisMockService  - Starting Kinesis Http2 Mock Service on port 4567 
[ioapp-compute-2] INFO  k.m.KinesisMockService  - Starting Kinesis Http1 Plain Mock Service on port 4568 

@munishchouhan
Copy link
Contributor

@etspaceman please share any other information which can help me to reproduce this issue

@kaspernielsen
Copy link

kaspernielsen commented Apr 29, 2021

I'm seeing a similar issue.

public class HelloWorld {

    static final Helper helper;

    static {
        Lookup l = MethodHandles.lookup();
        try {
            MethodHandle mh = l.findStatic(HelloWorld.class, "ffooo", MethodType.methodType(void.class));
            mh = MethodHandles.dropArguments(mh, 0, String.class);
            helper = new Helper(mh);
        } catch (ReflectiveOperationException e) {
            throw new Error(e);
        }
    }

    static void ffooo() {
        System.out.println("Works fine");
    }

    public static void main(String[] args) throws Throwable {
        helper.run();
    }

    static record Helper(MethodHandle mh) {

        public void run() throws Throwable {
            mh.invokeExact("dada");
        }
    }
}

Compiled with native-image HelloWorld --initialize-at-build-time=HelloWorld foobar

@munishchouhan
Copy link
Contributor

@kaspernielsen thanks for the reproducer, I am able to reproduce the issue
I will raise to our Dev team for further steps

@etspaceman
Copy link
Author

Thanks for the reproducer @kaspernielsen . @mcraj017 - I switched out the library that was causing my issue in my latest versions. The commit that I had linked had this issue. But it seems we have a much simpler reproducer here which is good.

@christianwimmer
Copy link

Is this still reproducible with GraalVM 21.1? We definitely fixed a bug recently that caused a similar exception.

@kaspernielsen
Copy link

kaspernielsen commented Apr 30, 2021 via email

@moorsu
Copy link

moorsu commented May 18, 2021

I am also encountering the same issue with 21.1

Exception in thread "main" java.lang.ClassCastException: java.lang.invoke.BoundMethodHandle$Species_LLLLLLLLLLLLL cannot be cast to java.lang.invoke.SimpleMethodHandle
	at com.oracle.svm.methodhandles.MethodHandleIntrinsicImpl.execute(MethodHandleIntrinsicImpl.java:258)
	at com.oracle.svm.methodhandles.Util_java_lang_invoke_MethodHandle.invokeInternal(Target_java_lang_invoke_MethodHandle.java:144)
	at java.lang.invoke.MethodHandle.invokeBasic(MethodHandle.java:79)
	at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(LambdaForm.java:76)
	at java.lang.invoke.LambdaForm.interpretName(LambdaForm.java:981)
	at java.lang.invoke.LambdaForm.interpretWithArguments(LambdaForm.java:958)
	at java.lang.invoke.MethodHandle.invokeBasic(MethodHandle.java:85)
	at java.lang.invoke.MethodHandle.invokeBasic(MethodHandle.java:0)
	at java.lang.invoke.LambdaForm$MH/15040032.invoke(LambdaForm$MH)

@moorsu
Copy link

moorsu commented May 30, 2021

Hi loicottet, Did you get a chance to look into it?. Thanks in advance!

@loicottet
Copy link
Member

The fix is ready and should be merged to master soon.

@loicottet
Copy link
Member

Fixed by 540eff5

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

7 participants