Skip to content

Commit

Permalink
Both class loaders compile. Now for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Apr 8, 2014
1 parent e1d9f71 commit 648b559
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ extends ClassLoader {
val uri = new URI(classUri)
val directory = uri.getPath

class ParentLoader(parent: ClassLoader) extends ClassLoader(parent) {
override def findClass(name: String): Class[_] = {
super.findClass(name)
}
}

val parentLoader = new ParentLoader(parent)

// Hadoop FileSystem object for our URI, if it isn't using HTTP
var fileSystem: FileSystem = {
if (uri.getScheme() == "http") {
Expand All @@ -51,10 +59,10 @@ extends ClassLoader {

override def findClass(name: String): Class[_] = {
userClassPathFirst match {
case true => findClassLocally(name).getOrElse(parent.findClass(name))
case true => findClassLocally(name).getOrElse(parentLoader.findClass(name))
case false => {
try {
parent.findClass(name)
parentLoader.findClass(name)
} catch {
case e: ClassNotFoundException => {
val classOption = findClassLocally(name)
Expand All @@ -68,7 +76,7 @@ extends ClassLoader {
}
}

def findClassLocaly(name: String): Option[Class[_]] = {
def findClassLocally(name: String): Option[Class[_]] = {
try {
val pathInDirectory = name.replace('.', '/') + ".class"
val inputStream = {
Expand Down

0 comments on commit 648b559

Please sign in to comment.