Skip to content

Warn when creating a new ivar table on JavaProxy wrapper#8613

Merged
headius merged 4 commits intojruby:masterfrom
headius:ivar_warning_on_java_proxy
Feb 6, 2025
Merged

Warn when creating a new ivar table on JavaProxy wrapper#8613
headius merged 4 commits intojruby:masterfrom
headius:ivar_warning_on_java_proxy

Conversation

@headius
Copy link
Member

@headius headius commented Feb 5, 2025

This warning was lost when we optimized variable updates to skip RubyBasicObject's setVariable as reported in #8611. The changes here restore the warning:

  • Move common logic for initializing the variable table to the VariableAccessor superclass.
  • Ensure all places where a new variable table is created check for JavaProxy and warn appropriately.

Note that field-based variable access does not have this same proxy check because JavaProxy will never use field-based variables.

@headius headius added this to the JRuby 9.4.12.0 milestone Feb 5, 2025
@headius headius marked this pull request as draft February 5, 2025 21:51
@headius
Copy link
Member Author

headius commented Feb 5, 2025

Do not merge until tests have been added.

The logic here was identical between NonVolatile and Stamped
accessors except for the full fence. Since these two are never
used at the same time, passing a fence flag in will constant fold
away and not impact behavior or performance.
The implementations of VariableAccessor bypass RubyBasicObject's
getVariable and setVariable, missing the warning check for non-
persistent Java objects. This duplicates that check along all
VariableAccessor paths to ensure we properly warn for ivars on a
non-persistent wrapper.

Fixes jruby#8611
@headius headius force-pushed the ivar_warning_on_java_proxy branch from 1d1fa3d to f58c347 Compare February 5, 2025 22:41
@headius
Copy link
Member Author

headius commented Feb 6, 2025

Specs added for ivar warning and singleton warning. I did not test the different modes because we're likely to remove all but one soon.

@headius headius marked this pull request as ready for review February 6, 2025 13:12
@headius headius merged commit ac80e82 into jruby:master Feb 6, 2025
95 checks passed
@headius headius deleted the ivar_warning_on_java_proxy branch February 6, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant