cursive
cursive copied to clipboard
Organize imports removes imported Java classes if method calls use reflection
If the only use of a Java class uses an overloaded method that is resolved in runtime, the class is marked as unused and removed by Organize imports. Adding type annotations to arguments to ensure the resolution happens AOT, marks the classes as used, and Organize imports acts fine.
Ran into issues with this using the Elasticsearch Java APIs, where constructors are overloaded for some request classes.