Skip to content

Introduce a DEFAULT visibility to indicate unspecified#8213

Merged
headius merged 2 commits intojruby:masterfrom
headius:default_visibility
May 29, 2024
Merged

Introduce a DEFAULT visibility to indicate unspecified#8213
headius merged 2 commits intojruby:masterfrom
headius:default_visibility

Conversation

@headius
Copy link
Member

@headius headius commented Apr 25, 2024

In #8146 we saw that DelegateClass can be broken by JRuby extensions that do not explicitly set their initialize methods to Visibility.PRIVATE. This is an error-prone requirement as detailed in #8210, since there's no indication that initialize is special and should always be private.

This patch introduces a "DEFAULT" visibility to be the default for the annotation. When binding methods using annotation processing, the DEFAULT visibility will translate itself to PRIVATE for the initialize method and PUBLIC for other cases. This ensures that initialize is always set to PRIVATE if no other visibility is specified, avoiding the bug. If initialize is set to some other visibility, it will keep that visibility.

Fixes #8210

In jruby#8146 we saw that DelegateClass can be broken by
JRuby extensions that do not explicitly set their initialize
methods to Visibility.PRIVATE. This is an error-prone requirement
as detailed in jruby#8210, since there's no indication that
initialize is special and should always be private.

This patch introduces a "DEFAULT" visibility to be the default for
the annotation. When binding methods using annotation processing,
the DEFAULT visibility will translate itself to PRIVATE for the
initialize method and PUBLIC for other cases. This ensures that
initialize is always set to PRIVATE if no other visibility is
specified, avoiding the bug. If initialize is set to some other
visibility, it will keep that visibility.

Fixes jruby#8210
@headius headius added this to the JRuby 10.0.0.0 milestone Apr 25, 2024
@headius headius modified the milestones: JRuby 10.0.0.0, JRuby 9.4.8.0 May 29, 2024
@headius headius merged commit f5e452d into jruby:master May 29, 2024
@headius headius deleted the default_visibility branch May 29, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requiring visibility=PRIVATE for native initialize is error-prone

1 participant