Skip to content

Commit

Permalink
remove support for aliasing Java indexed getters as Ruby readers (fixes
Browse files Browse the repository at this point in the history
#3262)

a rarely (if ever used) feature that looks a bit weird and was "not-complete" 
(indexed setters do not receive a special treat) and never documented
kares committed Sep 15, 2015
1 parent dcb99b9 commit 20fdb55
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -182,9 +182,7 @@ protected static void assignAliases(MethodInstaller installer, Map<String, Assig
if (javaPropertyName != null) {
if (rubyCasedName.startsWith("get_")) {
rubyPropertyName = rubyCasedName.substring(4);
if (argCount == 0 || // getFoo => foo
argCount == 1 && argTypes[0] == int.class) { // getFoo(int) => foo(int)

if (argCount == 0) { // getFoo => foo
addUnassignedAlias(javaPropertyName, assignedNames, installer);
addUnassignedAlias(rubyPropertyName, assignedNames, installer);
}
@@ -207,8 +205,7 @@ protected static void assignAliases(MethodInstaller installer, Map<String, Assig
if (resultType == boolean.class) {
// is_something?, contains_thing?
addUnassignedAlias(rubyCasedName + '?', assignedNames, installer);
if (rubyPropertyName != null) {
// something?
if (rubyPropertyName != null) { // something?
addUnassignedAlias(rubyPropertyName + '?', assignedNames, installer);
}
}
10 changes: 10 additions & 0 deletions test/jruby/test_higher_javasupport.rb
Original file line number Diff line number Diff line change
@@ -1359,6 +1359,16 @@ def test_float_always_coerces_to_java_float
end
end

# GH-3262
def test_indexed_bean_style_accessors_are_not_aliased
# ArgumentError: wrong number of arguments (0 for 1)
assert java.lang.Character.name
java.lang.Character.getName(42) # nothing raised
assert_raises(ArgumentError) do
java.lang.Character.name(42) # `getName(int)' NOT mapped to `name(i)'
end
end

def test_no_warnings_on_concurrent_package_const_initialization
output = with_stderr_captured do
threads = (0..10).map do # smt not yet initialized :

0 comments on commit 20fdb55

Please sign in to comment.