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

Support for Reflective Access to the Elements of Lambdas and Proxies via Reflection Metadata #6853

Closed
vjovanov opened this issue Jun 21, 2023 · 1 comment

Comments

@vjovanov
Copy link
Member

vjovanov commented Jun 21, 2023

TL;DR

Currently, it is impossible to reflectively access elements of lambdas and Proxy classes in Native Image. The reason is that the format of reflect-config.json can not refer to lambda and proxy types. The current JSON element name can't be used as lambdas and proxies don't have a stable class name to refer to.

This proposal would allow reflective access to proxy classes and lambda classes in Native Image by supporting proxies and lambdas in reachability metadata.

Goals

This proposal should add two new types of elements to reflect-config.json and jni-config.json:

  1. For proxies we propose referring to them via the list of interfaces in the following way:
{
   "proxy": ["interface1", "interface2"],
   "queryAllDeclaredFields": true
}
  1. For lambdas, we propose referring to the lambda via the capturing class of a lambda and the list of types that the lambda implements:
{
   "lambda": {
     "capturingClass": "Foo",
     "inheritedTypes": [ "java.lang.Runnable" ]
   },
   "queryAllDeclaredFields": true
}

These elements would then be accessible via reflection at runtime.

Non-Goals

Support the predefinition of lambdas or proxies.
Make proxy-config.json unnecessary, although this could be considered.

@vjovanov
Copy link
Member Author

vjovanov commented Nov 7, 2023

This item is superseded with #7476

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
@vjovanov @fniephaus and others