Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix JRUBY-6383

Scala integration breaks with 1.6.6

This has actually been "broken" since 1.6.0, since we were not
defining the symbolic names for any of the $ Scala methods. This
fix adds the symbolic names and leaves the originals intact.
  • Loading branch information...
commit 6c0234b7699f1873d669f5f3462502cbb4e21606 1 parent 6ff47b3
@headius headius authored
View
22 spec/java_integration/fixtures/MethodNames.java
@@ -63,6 +63,24 @@ public void setJConsecutiveCaps(Object value) {}
public String id() {return "foo";}
public String __id__() {return "foo";}
- // names that should be fixed by fixScalaNames
- public String $bslash() {return "$bslash";}
+ // names that should get aliases for Scala integration
+ public String $plus() {return "$plus";}
+ public String $minus() {return "$minus";}
+ public String $colon() {return "$colon";}
+ public String $div() {return "$div";}
+ public String $eq() {return "$eq";}
+ public String $less() {return "$less";}
+ public String $greater() {return "$greater";}
+ public String $bslash() {return "$bslash";}
+ public String $hash() {return "$hash";}
+ public String $times() {return "$times";}
+ public String $bang() {return "$bang";}
+ public String $at() {return "$at";}
+ public String $percent() {return "$percent";}
+ public String $up() {return "$up";}
+ public String $amp() {return "$amp";}
+ public String $tilde() {return "$tilde";}
+ public String $qmark() {return "$qmark";}
+ public String $bar() {return "$bar";}
+ public String $plus$eq() {return "$plus$eq";}
}
View
44 spec/java_integration/methods/naming_spec.rb
@@ -146,11 +146,49 @@
obj.__id__.should_not == "foo"
lambda {obj.__send__}.should raise_error(ArgumentError)
end
-
- it "has methods named $bslash" do
- members.should have_strings("\\")
+
+ it "aliases scala names to symbolic equivalents" do
obj = MethodNames.new
+
+ obj.send(:"+").should == "$plus"
+ obj.send(:"-").should == "$minus"
+ obj.send(:":").should == "$colon"
+ obj.send(:"/").should == "$div"
+ obj.send(:"=").should == "$eq"
+ obj.send(:"<").should == "$less"
+ obj.send(:">").should == "$greater"
obj.send(:"\\").should == "$bslash"
+ obj.send(:"#").should == "$hash"
+ obj.send(:"*").should == "$times"
+ obj.send(:"!").should == "$bang"
+ obj.send(:"@").should == "$at"
+ obj.send(:"%").should == "$percent"
+ obj.send(:"^").should == "$up"
+ obj.send(:"&").should == "$amp"
+ obj.send(:"~").should == "$tilde"
+ obj.send(:"?").should == "$qmark"
+ obj.send(:"|").should == "$bar"
+ obj.send(:"+=").should == "$plus$eq"
+
+ obj.send(:"$plus").should == "$plus"
+ obj.send(:"$minus").should == "$minus"
+ obj.send(:"$colon").should == "$colon"
+ obj.send(:"$div").should == "$div"
+ obj.send(:"$eq").should == "$eq"
+ obj.send(:"$less").should == "$less"
+ obj.send(:"$greater").should == "$greater"
+ obj.send(:"$bslash").should == "$bslash"
+ obj.send(:"$hash").should == "$hash"
+ obj.send(:"$times").should == "$times"
+ obj.send(:"$bang").should == "$bang"
+ obj.send(:"$at").should == "$at"
+ obj.send(:"$percent").should == "$percent"
+ obj.send(:"$up").should == "$up"
+ obj.send(:"$amp").should == "$amp"
+ obj.send(:"$tilde").should == "$tilde"
+ obj.send(:"$qmark").should == "$qmark"
+ obj.send(:"$bar").should == "$bar"
+ obj.send(:"$plus$eq").should == "$plus$eq"
end
end
View
10 src/org/jruby/javasupport/JavaClass.java
@@ -745,6 +745,11 @@ private static void assignAliases(MethodInstaller installer, Map<String, Assigne
addUnassignedAlias("[]=", assignedNames, installer);
}
+ // Scala aliases for $ method names
+ if (name.startsWith("$")) {
+ addUnassignedAlias(fixScalaNames(name), assignedNames, installer);
+ }
+
// Add property name aliases
if (javaPropertyName != null) {
if (rubyCasedName.startsWith("get_")) {
@@ -955,11 +960,6 @@ private void setupClassMethods(Class<?> javaClass, InitializerState state) {
Method method = methods[i];
String name = method.getName();
- // Fix Scala names to be their Ruby equivalents
- if (name.startsWith("$")) {
- name = fixScalaNames(name);
- }
-
if (Modifier.isStatic(method.getModifiers())) {
AssignedName assignedName = state.staticNames.get(name);
Please sign in to comment.
Something went wrong with that request. Please try again.