Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jruby/jruby
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Dec 5, 2014
2 parents d454f28 + 59c9f74 commit 5a441e6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
9 changes: 2 additions & 7 deletions core/src/main/java/org/jruby/RubyClassPathVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,10 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {
paths = context.runtime.newArray(obj).toJavaArray();
}

boolean is1_8 = context.getRuntime().is1_8();
for (IRubyObject path: paths) {
String ss = path.convertToString().toString();
try {
URL url = getURL(path.convertToString().toString());
if (url.getProtocol().equals("file")) {
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
url = getURL(path.convertToString().toString());
}
URL url = getURL(ss);
getRuntime().getJRubyClassLoader().addURL(url);
} catch (MalformedURLException mue) {
throw getRuntime().newArgumentError(mue.getLocalizedMessage());
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3510,7 +3510,12 @@ private Operand[] adjustVariableDepth(Operand[] args, int depthFromSuper) {
Operand[] newArgs = new Operand[args.length];

for (int i = 0; i < args.length; i++) {
newArgs[i] = ((DepthCloneable) args[i]).cloneForDepth(depthFromSuper);
// Because of keyword args, we can have a keyword-arg hash in the call args.
if (args[i] instanceof Hash) {
newArgs[i] = ((Hash) args[i]).cloneForLVarDepth(depthFromSuper);
} else {
newArgs[i] = ((DepthCloneable) args[i]).cloneForDepth(depthFromSuper);
}
}

return newArgs;
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public void addUsedVariables(List<Variable> l) {
}
}

public Operand cloneForLVarDepth(int newDepth) {
List<KeyValuePair<Operand, Operand>> newPairs = new java.util.ArrayList<KeyValuePair<Operand, Operand>>();
for (KeyValuePair<Operand, Operand> pair : pairs) {
newPairs.add(new KeyValuePair(pair.getKey(), ((DepthCloneable) pair.getValue()).cloneForDepth(newDepth)));
}
return new Hash(newPairs, isKWArgsHash);
}

@Override
public Operand cloneForInlining(CloneInfo ii) {
if (hasKnownValue())
Expand Down
7 changes: 4 additions & 3 deletions spec/java_integration/globals/classpath_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
describe "<<" do
it "accepts an object" do
$CLASSPATH << "file"
$CLASSPATH.to_a.include?("file:#{File.expand_path('file')}").should == true
$CLASSPATH.to_a.include?("file:file").should == true
end

it "accepts an array" do
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) do
$CLASSPATH << Dir.glob("*.jar")
($CLASSPATH.to_a.include?("file:#{File.expand_path('jruby.jar')}")).should == true
($CLASSPATH.to_a.include?("file:jruby.jar") ||
$CLASSPATH.to_a.include?("file:jruby-complete.jar") ).should == true
end
end
end
end
end

0 comments on commit 5a441e6

Please sign in to comment.