Skip to content

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

@vjovanov

Description

@vjovanov

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions