Skip to content

[native-image] Unsupported type java.lang.invoke.MemberName is reachable #1895

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
kaspernielsen opened this issue Nov 27, 2019 · 3 comments
Closed
Assignees

Comments

@kaspernielsen
Copy link

kaspernielsen commented Nov 27, 2019

The following piece of code fails for image generation with

com.oracle.svm.core.util.UserError$UserException: 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.
Detailed message:
Trace:
	at parsing java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1264)
Call path from entry point to java.lang.invoke.MethodHandles$Lookup.findConstructor(Class, MethodType):
	at java.lang.invoke.MethodHandles$Lookup.findConstructor(MethodHandles.java:1260)
public class HelloWorld {
    static {
        getEmptyConstructor(HelloWorld.class);
    }

    public static void main(String... args) {
        getEmptyConstructor(HelloWorld.class);
    }

    static void getEmptyConstructor(Class<?> c) {
        try {
            MethodHandles.lookup().findConstructor(c, MethodType.methodType(void.class));
        } catch (ReflectiveOperationException e) {
            throw new Error(e);
        }
    }
}

Pretty must all reflective methods on MethodsHandles.Lookup fails in a similar way

@kaspernielsen
Copy link
Author

kaspernielsen commented Nov 27, 2019

A simpler example

public class HelloWorld {

    static final Constructor<?> CON = HelloWorld.class.getDeclaredConstructors()[0];

    public static void main(String... args) throws IllegalAccessException {
        MethodHandles.lookup().unreflectConstructor(CON);
    }
}

@kaspernielsen
Copy link
Author

kaspernielsen commented Nov 27, 2019

I run with --initialize-at-build-time= HelloWorld

@cstancu cstancu self-assigned this Nov 27, 2019
@cstancu cstancu assigned loicottet and unassigned cstancu Oct 13, 2020
@cstancu
Copy link
Member

cstancu commented Oct 13, 2020

The underlying issue here is incomplete MethodHandle support. That is under development and is being tracked by #2761.

@cstancu cstancu closed this as completed Oct 13, 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

3 participants