lucene icon indicating copy to clipboard operation
lucene copied to clipboard

LUCENE-10322: Enable -Xlint:path and -Xlint:-exports

Open spike-liu opened this issue 3 years ago • 5 comments

https://issues.apache.org/jira/browse/LUCENE-10322

#11358

spike-liu avatar Feb 15 '22 08:02 spike-liu

why do we have to make all these internal classes public to do this? I don't think this is a good tradeoff.

rmuir avatar Feb 15 '22 10:02 rmuir

I would leave -Xlint:exports entirely out of the patch - this is not easily fixable; the module API is broken in that it exposes types that are not public but making them public is not really a solution.

dweiss avatar Feb 15 '22 10:02 dweiss

why do we have to make all these internal classes public to do this? I don't think this is a good tradeoff.

Thanks for your review, Robert. Just like Dawid mentioned, simply making them public is really not a good solution. + 1 example for your reference:

  • public class ByteBufferIndexInput uses private class ByteBufferGuard as a parameter of method; image

  • org.apache.lucene.search.suggest.document.NRTSuggester uses ByteBufferIndexInput like below:

image

Hence it violates the existing rule of java module system, which seems a bit hard to comply in our case right now.

spike-liu avatar Feb 16 '22 07:02 spike-liu

Yeah, those are actually API bugs? We have public methods that have non-public classes in their signature. Looks like this will be more complex to fix up.

In this example of ByteBufferIndexInput.newInstance and its ByteBufferGuard parameter, I think a better solution is to make ByteBufferIndexInput.newInstance package-private. The only callers are ByteBuffersDirectory and MMapDirectory which are in the same package. Then we don't need to make ByteBufferGuard public.

rmuir avatar Feb 16 '22 10:02 rmuir

Yeah, those are actually API bugs?

They do look like API issues to me. Useful warning, by the way.

dweiss avatar Feb 16 '22 11:02 dweiss

Yeah, those are actually API bugs?

They do look like API issues to me. Useful warning, by the way.

It's awesome that this change uncovered such API bugs! Thanks @spike-liu.

Are these added linting arguments still worth pursuing? Have we solved this in some other manner? I think generally we could use all the static (compile time) checking that we can safely enable to make our dev more efficient...

mikemccand avatar Nov 02 '23 10:11 mikemccand

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

github-actions[bot] avatar Jan 08 '24 12:01 github-actions[bot]