Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 20cd102a8050
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 08da5c5a87ab
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Feb 13, 2015

  1. Copy the full SHA
    08da5c5 View commit details
Original file line number Diff line number Diff line change
@@ -454,10 +454,14 @@ public void initializeAfterMethodsAdded() {
}

public void loadRubyCore(String fileName) {
loadRubyCore(fileName, "core:/");
}

public void loadRubyCore(String fileName, String prefix) {
final Source source;

try {
source = Source.fromReader(new InputStreamReader(getRubyCoreInputStream(fileName), StandardCharsets.UTF_8), "core:/" + fileName);
source = Source.fromReader(new InputStreamReader(getRubyCoreInputStream(fileName), StandardCharsets.UTF_8), prefix + fileName);
} catch (IOException e) {
throw new RuntimeException(e);
}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.util.Arrays;

/**
@@ -114,7 +115,29 @@ private boolean requireFile(String fileName, RubyNode currentNode) throws IOExce
// We expect '/' in various classpath URLs, so normalize Windows file paths to use '/'
fileName = fileName.replace('\\', '/');

if (fileName.startsWith("core:/")) {
if (fileName.startsWith("uri:classloader:/")) {
// TODO CS 13-Feb-15 this uri:classloader:/ and core:/ thing is a hack - simplify it

for (Object loaded : Arrays.asList(context.getCoreLibrary().getLoadedFeatures().slowToArray())) {
if (loaded.toString().equals(fileName)) {
return true;
}
}

String coreFileName = fileName.substring("uri:classloader:/".length());

coreFileName = FileSystems.getDefault().getPath(coreFileName).normalize().toString();

if (context.getRuntime().getLoadService().getClassPathResource(context.getRuntime().getJRubyClassLoader(), coreFileName) == null) {
return false;
}

context.getCoreLibrary().loadRubyCore(coreFileName, "uri:classloader:/");
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(fileName));

return true;
}
else if (fileName.startsWith("core:/")) {
for (Object loaded : Arrays.asList(context.getCoreLibrary().getLoadedFeatures().slowToArray())) {
if (loaded.toString().equals(fileName)) {
return true;
@@ -127,7 +150,8 @@ private boolean requireFile(String fileName, RubyNode currentNode) throws IOExce
return false;
}

context.getCoreLibrary().loadRubyCore(coreFileName);

context.getCoreLibrary().loadRubyCore(coreFileName, "core:/");
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(fileName));

return true;