Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ModuleLoader special handling.
Added as part of the work towards getting NQP JVM to build itself in
order to support bootstrapping.
  • Loading branch information
jnthn committed Apr 14, 2013
1 parent d26aaf7 commit 9127bcd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/org/perl6/nqp/runtime/LibraryLoader.java
Expand Up @@ -8,14 +8,26 @@
public class LibraryLoader {
public static HashSet<String> loaded = new HashSet<String>();

public void load(ThreadContext tc, String filename) {
public void load(ThreadContext tc, String origFilename) {
// Don't load the same thing multiple times.
if (loaded.contains(filename))
if (loaded.contains(origFilename))
return;

try {
// Read in class data.
String filename = origFilename;
File file = new File(filename);
if (!file.exists() && filename.equals("ModuleLoader.class")) {
/* We special case the initial ModuleLoader loading. */
String[] cps = System.getProperty("java.class.path").split("[:;]");
for (int i = 0; i < cps.length; i++) {
file = new File(cps[i] + "/" + filename);
if (file.exists()) {
filename = cps[i] + "/" + filename;
break;
}
}
}
byte[] bytes = new byte[(int)file.length()];
DataInputStream dis = new DataInputStream((new FileInputStream(filename)));
dis.readFully(bytes);
Expand All @@ -28,7 +40,7 @@ public void load(ThreadContext tc, String filename) {
cu.runLoadIfAvailable(tc);

// Note that we already loaded it.
loaded.add(filename);
loaded.add(origFilename);
} catch (Exception e) {
throw ExceptionHandling.dieInternal(tc, e.getMessage());
}
Expand Down

0 comments on commit 9127bcd

Please sign in to comment.