docs/reference-manual/native-image/guides/configure-dynamic-proxies.md
You can generate dynamic proxy classes at build time by specifying the list of interfaces that they implement. This can be done by adding a reflection entry in the reachability-metadata.json configuration file. For example:
{
"reflection": [
{
"type": {
"proxy": ["java.lang.AutoCloseable", "java.util.Comparator"]
}
},
{
"type": {
"proxy":["java.util.Comparator"]
}
},
{
"type": {
"proxy":["java.util.List"]
}
}
]
}
Note: The order of the specified proxy interfaces is significant: two requests for a
Proxyclass with the same combination of interfaces but in a different order will result in two distinct behaviors (for more detailed information, refer to classProxy).
The java.lang.reflect.Proxy API also enables you to create a dynamic proxy that does not implement any user provided interfaces.
In this case the generated dynamic proxy class implements java.lang.reflect.Proxy only.