Lots and lots of work to get things to compile without warnings

This commit is contained in:
Viktor Klang 2012-06-13 15:44:24 +02:00
parent 6b468d8856
commit 4ee2033761
12 changed files with 51 additions and 46 deletions

View file

@ -650,6 +650,7 @@ private[akka] class ActorCell(
case Terminate() terminate()
case Supervise(child) supervise(child)
case ChildTerminated(child) handleChildTerminated(child)
case NoMessage //FIXME What should we do?
}
} catch {
case e @ (_: InterruptedException | NonFatal(_)) handleInvokeFailure(e, "error while processing " + message)

View file

@ -5,6 +5,7 @@ package akka.actor
import akka.util.NonFatal
import java.lang.reflect.InvocationTargetException
import scala.reflect.ClassTag
/**
* The DynamicAccess implementation is the class which is used for
@ -24,7 +25,7 @@ abstract class DynamicAccess {
* val obj = DynamicAccess.createInstanceFor(clazz, Seq(classOf[Config] -> config, classOf[String] -> name))
* }}}
*/
def createInstanceFor[T: ClassManifest](clazz: Class[_], args: Seq[(Class[_], AnyRef)]): Either[Throwable, T] = {
def createInstanceFor[T: ClassTag](clazz: Class[_], args: Seq[(Class[_], AnyRef)]): Either[Throwable, T] = {
val types = args.map(_._1).toArray
val values = args.map(_._2).toArray
withErrorHandling {
@ -40,7 +41,7 @@ abstract class DynamicAccess {
* Obtain a `Class[_]` object loaded with the right class loader (i.e. the one
* returned by `classLoader`).
*/
def getClassFor[T: ClassManifest](fqcn: String): Either[Throwable, Class[_ <: T]]
def getClassFor[T: ClassTag](fqcn: String): Either[Throwable, Class[_ <: T]]
/**
* Obtain an object conforming to the type T, which is expected to be
@ -49,12 +50,12 @@ abstract class DynamicAccess {
* `args` argument. The exact usage of args depends on which type is requested,
* see the relevant requesting code for details.
*/
def createInstanceFor[T: ClassManifest](fqcn: String, args: Seq[(Class[_], AnyRef)]): Either[Throwable, T]
def createInstanceFor[T: ClassTag](fqcn: String, args: Seq[(Class[_], AnyRef)]): Either[Throwable, T]
/**
* Obtain the Scala object instance for the given fully-qualified class name, if there is one.
*/
def getObjectFor[T: ClassManifest](fqcn: String): Either[Throwable, T]
def getObjectFor[T: ClassTag](fqcn: String): Either[Throwable, T]
/**
* This is the class loader to be used in those special cases where the
@ -89,7 +90,7 @@ abstract class DynamicAccess {
*/
class ReflectiveDynamicAccess(val classLoader: ClassLoader) extends DynamicAccess {
//FIXME switch to Scala Reflection for 2.10
override def getClassFor[T: ClassManifest](fqcn: String): Either[Throwable, Class[_ <: T]] =
override def getClassFor[T: ClassTag](fqcn: String): Either[Throwable, Class[_ <: T]] =
try {
val c = classLoader.loadClass(fqcn).asInstanceOf[Class[_ <: T]]
val t = classManifest[T].erasure
@ -98,7 +99,7 @@ class ReflectiveDynamicAccess(val classLoader: ClassLoader) extends DynamicAcces
case NonFatal(e) Left(e)
}
override def createInstanceFor[T: ClassManifest](fqcn: String, args: Seq[(Class[_], AnyRef)]): Either[Throwable, T] =
override def createInstanceFor[T: ClassTag](fqcn: String, args: Seq[(Class[_], AnyRef)]): Either[Throwable, T] =
getClassFor(fqcn).fold(Left(_), { c
val types = args.map(_._1).toArray
val values = args.map(_._2).toArray
@ -111,7 +112,7 @@ class ReflectiveDynamicAccess(val classLoader: ClassLoader) extends DynamicAcces
}
})
override def getObjectFor[T: ClassManifest](fqcn: String): Either[Throwable, T] = {
override def getObjectFor[T: ClassTag](fqcn: String): Either[Throwable, T] = {
getClassFor(fqcn).fold(Left(_), { c
withErrorHandling {
val module = c.getDeclaredField("MODULE$")

View file

@ -3,6 +3,8 @@
*/
package akka.actor
import scala.reflect.ClassTag
/**
* The basic ActorSystem covers all that is needed for locally running actors,
* using futures and so on. In addition, more features can hook into it and
@ -92,12 +94,12 @@ trait ExtensionIdProvider {
* }
* }}}
*/
abstract class ExtensionKey[T <: Extension](implicit m: ClassManifest[T]) extends ExtensionId[T] with ExtensionIdProvider {
def this(clazz: Class[T]) = this()(ClassManifest.fromClass(clazz))
abstract class ExtensionKey[T <: Extension](implicit m: ClassTag[T]) extends ExtensionId[T] with ExtensionIdProvider {
def this(clazz: Class[T]) = this()(ClassTag(clazz))
override def lookup(): ExtensionId[T] = this
def createExtension(system: ExtendedActorSystem): T =
system.dynamicAccess.createInstanceFor[T](m.erasure, Seq(classOf[ExtendedActorSystem] -> system)) match {
system.dynamicAccess.createInstanceFor[T](m.runtimeClass, Seq(classOf[ExtendedActorSystem] -> system)) match {
case Left(ex) throw ex
case Right(r) r
}

View file

@ -6,7 +6,7 @@ package akka.actor
import akka.dispatch._
import akka.japi.Creator
import collection.immutable.Stack
import scala.reflect.ClassTag
import akka.routing._
/**
@ -49,8 +49,8 @@ object Props {
*
* Scala API.
*/
def apply[T <: Actor: ClassManifest](): Props =
default.withCreator(implicitly[ClassManifest[T]].erasure.asInstanceOf[Class[_ <: Actor]])
def apply[T <: Actor: ClassTag](): Props =
default.withCreator(implicitly[ClassTag[T]].runtimeClass.asInstanceOf[Class[_ <: Actor]])
/**
* Returns a Props that has default values except for "creator" which will be a function that creates an instance

View file

@ -11,7 +11,7 @@ import java.util.concurrent.atomic.{ AtomicReference ⇒ AtomVar }
import akka.dispatch._
import java.util.concurrent.TimeoutException
import java.util.concurrent.TimeUnit.MILLISECONDS
import akka.actor.TypedActor.TypedActorInvocationHandler
import scala.reflect.ClassTag
import akka.serialization.{ JavaSerializer, SerializationExtension }
import java.io.ObjectStreamException
@ -404,7 +404,7 @@ object TypedActor extends ExtensionId[TypedActorExtension] with ExtensionIdProvi
val f = ask(actor, m)(timeout)
(try { Await.ready(f, timeout.duration).value } catch { case _: TimeoutException None }) match {
case None | Some(Right(null)) if (m.returnsJOption_?) JOption.none[Any] else None
case Some(Right(joption: AnyRef)) joption
case Some(Right(joption)) joption.asInstanceOf[AnyRef]
case Some(Left(ex)) throw ex
}
case m Await.result(ask(actor, m)(timeout), timeout.duration).asInstanceOf[AnyRef]
@ -481,8 +481,8 @@ object TypedProps {
*
* Scala API
*/
def apply[T <: AnyRef: ClassManifest](): TypedProps[T] =
new TypedProps[T](implicitly[ClassManifest[T]].erasure.asInstanceOf[Class[T]])
def apply[T <: AnyRef: ClassTag](): TypedProps[T] =
new TypedProps[T](implicitly[ClassTag[T]].runtimeClass.asInstanceOf[Class[T]])
}
/**

View file

@ -223,8 +223,7 @@ private[akka] object MessageDispatcher {
def printActors: Unit = if (debug) {
for {
d actors.keys
val c = println(d + " inhabitants: " + d.inhabitants)
a actors.valueIterator(d)
a { println(d + " inhabitants: " + d.inhabitants); actors.valueIterator(d) }
} {
val status = if (a.isTerminated) " (terminated)" else " (alive)"
val messages = a match {

View file

@ -8,6 +8,7 @@ import akka.event.Logging.Error
import scala.Option
import akka.japi.{ Function JFunc, Option JOption }
import scala.util.continuations._
import scala.reflect.ClassTag
import java.lang.{ Iterable JIterable }
import java.util.{ LinkedList JLinkedList }
import scala.annotation.tailrec
@ -637,17 +638,17 @@ sealed trait Future[+T] extends Await.Awaitable[T] {
* Creates a new Future[A] which is completed with this Future's result if
* that conforms to A's erased type or a ClassCastException otherwise.
*
* When used from Java, to create the Manifest, use:
* import static akka.japi.Util.manifest;
* future.mapTo(manifest(MyClass.class));
* When used from Java, to create the ClassTag, use:
* import static akka.japi.Util.classTag;
* future.mapTo(classTag(MyClass.class));
*/
final def mapTo[A](implicit m: Manifest[A]): Future[A] = {
final def mapTo[A](implicit m: ClassTag[A]): Future[A] = {
val fa = Promise[A]()
onComplete {
case l: Left[_, _] fa complete l.asInstanceOf[Either[Throwable, A]]
case Right(t)
fa complete (try {
Right(BoxedType(m.erasure).cast(t).asInstanceOf[A])
Right(BoxedType(m.runtimeClass).cast(t).asInstanceOf[A])
} catch {
case e: ClassCastException Left(e)
})

View file

@ -5,6 +5,7 @@
package akka.japi
import scala.Some
import scala.reflect.ClassTag
/**
* A Function interface. Used to create first-class-functions is Java.
@ -116,5 +117,5 @@ object Util {
/**
* Given a Class returns a Scala Manifest of that Class
*/
def manifest[T](clazz: Class[T]): Manifest[T] = Manifest.classType(clazz)
def classTag[T](clazz: Class[T]): ClassTag[T] = ClassTag(clazz)
}

View file

@ -131,7 +131,7 @@ private[akka] class DaemonMsgCreateSerializer(val system: ExtendedActorSystem) e
case Left(e) throw e
}
protected def deserialize[T: ClassManifest](data: ByteString, clazz: Class[T]): T = {
protected def deserialize[T: ClassTag](data: ByteString, clazz: Class[T]): T = {
val bytes = data.toByteArray
serialization.deserialize(bytes, clazz) match {
case Right(x) if classManifest[T].erasure.isInstance(x) x.asInstanceOf[T]

View file

@ -4,7 +4,7 @@
package sample.fsm.buncher
import akka.actor.ActorRefFactory
import scala.reflect.ClassManifest
import scala.reflect.ClassTag
import akka.util.Duration
import akka.actor.{ FSM, Actor, ActorRef }
@ -28,7 +28,7 @@ object GenericBuncher {
class MsgExtractor[A: Manifest] {
def unapply(m: AnyRef): Option[A] = {
if (ClassManifest.fromClass(m.getClass) <:< manifest[A]) {
if (ClassTag.fromClass(m.getClass) <:< manifest[A]) {
Some(m.asInstanceOf[A])
} else {
None

View file

@ -34,7 +34,7 @@ object ZeroMQExtension extends ExtensionId[ZeroMQExtension] with ExtensionIdProv
private val minVersion = JZMQ.makeVersion(2, 1, 0)
private[zeromq] def check[TOption <: SocketOption: Manifest](parameters: Seq[SocketOption]) =
parameters exists { p ClassManifest.singleType(p) <:< manifest[TOption] }
parameters exists { p ClassTag.singleType(p) <:< manifest[TOption] }
}
/**

View file

@ -500,7 +500,7 @@ object Dependency {
val protobuf = "com.google.protobuf" % "protobuf-java" % V.Protobuf // New BSD
val scalaStm = "org.scala-tools" %% "scala-stm" % V.ScalaStm // Modified BSD (Scala)
val slf4jApi = "org.slf4j" % "slf4j-api" % V.Slf4j // MIT
val zeroMQ = "org.zeromq" % "zeromq-scala-binding_2.9.1" % "0.0.6" // ApacheV2
val zeroMQ = "org.zeromq" %% "zeromq-scala-binding" % "0.0.6" // ApacheV2
// Test
@ -510,9 +510,9 @@ object Dependency {
val junit = "junit" % "junit" % "4.5" % "test" // Common Public License 1.0
val logback = "ch.qos.logback" % "logback-classic" % V.Logback % "test" // EPL 1.0 / LGPL 2.1
val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" // MIT
val scalatest = "org.scalatest" % "scalatest_2.9.1" % V.Scalatest % "test" // ApacheV2
val scalacheck = "org.scala-tools.testing" % "scalacheck_2.9.1" % "1.9" % "test" // New BSD
val specs2 = "org.specs2" % "specs2_2.9.1" % "1.9" % "test" // Modified BSD / ApacheV2
val scalatest = "org.scalatest" %% "scalatest" % V.Scalatest % "test" // ApacheV2
val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "1.9" % "test" // New BSD
val specs2 = "org.specs2" %% "specs2" % "1.9" % "test" // Modified BSD / ApacheV2
}
}