Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
Using Class.forName instead of getClass.getClassLoader.loadClass
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Kutcharian committed Nov 29, 2012
1 parent 4b1174c commit 17562c9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/scala/com/twitter/libkestrel/Journal.scala
Expand Up @@ -62,19 +62,22 @@ object Journal {
} }


private[libkestrel] val NoCondition = (_: QueueItem) => true private[libkestrel] val NoCondition = (_: QueueItem) => true


//Dynamically load ConcurrentLinkedDeque so we don't have a hard dependence on Java 7
private[this] val dequeClass: Class[_] = { private[this] val dequeClass: Class[_] = {
//First try to see java.util.concurrent.ConcurrentLinkedDeque exists //First try to see java.util.concurrent.ConcurrentLinkedDeque exists
try { try {
getClass.getClassLoader.loadClass("java.util.concurrent.ConcurrentLinkedDeque") Class.forName("java.util.concurrent.ConcurrentLinkedDeque")
} catch { } catch {
//Now try to see if jsr166y is available on the classpath //Now try to see if jsr166y is available on the classpath
case e:ClassNotFoundException => case e:ClassNotFoundException =>
try { try {
getClass.getClassLoader.loadClass("jsr166y.ConcurrentLinkedDeque") Class.forName("jsr166y.ConcurrentLinkedDeque")
} catch { } catch {
case e:ClassNotFoundException => sys.error("Could not find a class for ConcurrentLinkedDeque. You either need to be running Java 7+ or supply js166y jar.") case e:ClassNotFoundException =>
} throw new ClassNotFoundException("Could not find an appropriate class for ConcurrentLinkedDeque. " +
"You either need to be running Java 7+ or supply js166y jar.")
}
} }
} }


Expand Down

0 comments on commit 17562c9

Please sign in to comment.