cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Organize imports removes imported Java classes if method calls use reflection

Open Sardtok opened this issue 2 years ago • 0 comments

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.

Sardtok avatar Sep 27 '22 10:09 Sardtok