On Wed, 7 May 2025 15:24:04 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

>> Further, if you call `setAccessibile` in connection with `--add-opens`, 
>> which your above code snippet does, you can even call _private_ methods.
>> 
>> So at the risk of repeating myself, there is no concern that making this 
>> method public exposes it to applications. However, making it package-scope 
>> if it doesn't need to be public, is a best practice if it doesn't need to be 
>> accessed outside the package.
>
> yes, I agree - thanks for the discussion!
> 
> (and `setAccessible()` is not needed with `--add-opens`)
> 
> I withdraw my comments - making these methods `private` is not needed, 
> `public` or package-scope is fine.

> So at the risk of repeating myself, there is no concern that making this 
> method public exposes it to applications. However, making it package-scope if 
> it doesn't need to be public, is a best practice if it doesn't need to be 
> accessed outside the package.

These methods can have any visibility and it doesn't change their semantics at 
all, because the methods are declared in a private nested class (so they are 
not visible outside of the enclosing class). As a reminder, the enclosing class 
has access even to private members of its nested classes. The reason I chose to 
make the methods public is merely to indicate "this is supposed to be public 
API for the enclosing class".

I'm not inclined to change that, as all of the arguments presented so far do 
not apply. The methods are not visible in other top-level classes (even in the 
same package), and making them any less visible doesn't change that.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1655#discussion_r2079422989

Reply via email to