Skip to content

Setting an instance var on a Java object no longer warns #8611

@headius

Description

@headius

In 1.7 we stopped caching the wrappers for Java objects that enter Ruby, and introduced warnings for two cases that could be affected:

  • creating a singleton object from one of these wrappers
  • setting instance variables on one of these wrappers

The singleton case still warns today (JRuby 9.4.12.0-SNAPSHOT on master), but the instance variable case does not:

$ jruby -e 'class << java.lang.Object.new; end'
-e:1: warning: singleton on non-persistent Java type Java::JavaLang::Object (https://github.com/jruby/jruby/wiki/Persistence)
$ jruby -e 'java.lang.Object.new.instance_variable_set(:@foo, 1)'
$ jruby -X-C -e 'java.lang.Object.new.instance_variable_set(:@foo, 1)'
$

We must restore this warning and add tests to ensure it is not broken again.

Relates to #8224.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions