diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-10 15:08:54 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-10 15:08:54 +0000 |
commit | ca47241bf8895d6c3a73a619c677bb6a2849a599 (patch) | |
tree | 8ad1932131f6f330730c652550e96d375bd61c62 /src | |
parent | 8821b0f220c62faf1e8c9e21eac3563acb98964e (diff) | |
download | scala-ca47241bf8895d6c3a73a619c677bb6a2849a599.tar.gz scala-ca47241bf8895d6c3a73a619c677bb6a2849a599.tar.bz2 scala-ca47241bf8895d6c3a73a619c677bb6a2849a599.zip |
Batting back a java.rmi.* dependency.
The scala gwt project does not like have a sudden dependency on
java.rmi.Remote show up in the mail. Review by grek.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/internal/AnnotationInfos.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/reflect/internal/Definitions.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 32 |
3 files changed, 18 insertions, 20 deletions
diff --git a/src/compiler/scala/reflect/internal/AnnotationInfos.scala b/src/compiler/scala/reflect/internal/AnnotationInfos.scala index 57722593d4..c096d14b76 100644 --- a/src/compiler/scala/reflect/internal/AnnotationInfos.scala +++ b/src/compiler/scala/reflect/internal/AnnotationInfos.scala @@ -28,7 +28,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable => /** Symbols of any @throws annotations on this symbol. */ - def throwsAnnotations() = annotations collect { + def throwsAnnotations(): List[Symbol] = annotations collect { case AnnotationInfo(tp, Literal(Constant(tpe: Type)) :: Nil, _) if tp.typeSymbol == ThrowsClass => tpe.typeSymbol } diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index d816ba247d..654639adae 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -247,6 +247,9 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val SerializableClass = getClass("scala.Serializable") lazy val JavaSerializableClass = getClass(sn.JavaSerializable) lazy val ComparableClass = getClass("java.lang.Comparable") + lazy val JavaCloneableClass = getClass("java.lang.Cloneable") + lazy val RemoteInterfaceClass = getClass("java.rmi.Remote") + lazy val RemoteExceptionClass = getClass("java.rmi.RemoteException") lazy val RepeatedParamClass = newCovariantPolyClass( ScalaPackageClass, @@ -626,6 +629,7 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val ParamTargetClass = getMetaAnnotation("param") lazy val SetterTargetClass = getMetaAnnotation("setter") + private def getMetaAnnotation(name: String) = getClass("scala.annotation.meta." + name) def isMetaAnnotation(sym: Symbol): Boolean = metaAnnotations(sym) || ( // Trying to allow for deprecated locations diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 8408965afe..11178ac0f6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -36,8 +36,8 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with AnyClass, ObjectClass, ThrowsClass, ThrowableClass, ClassfileAnnotationClass, SerializableClass, StringClass, ClassClass, FunctionClass, DeprecatedAttr, SerializableAttr, SerialVersionUIDAttr, VolatileAttr, - TransientAttr, CloneableAttr, RemoteAttr, - hasJavaMainMethod + TransientAttr, CloneableAttr, RemoteAttr, JavaCloneableClass, + RemoteInterfaceClass, RemoteExceptionClass, hasJavaMainMethod } val phaseName = "jvm" @@ -185,15 +185,13 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val BeanDisplayNameAttr = definitions.getClass("scala.beans.BeanDisplayName") val BeanDescriptionAttr = definitions.getClass("scala.beans.BeanDescription") - lazy val annotationInterfaces = List( - SerializableAttr -> SerializableClass.tpe, - CloneableAttr -> CloneableClass.tpe, - RemoteAttr -> RemoteInterface.tpe - ) - - lazy val CloneableClass = definitions.getClass("java.lang.Cloneable") - lazy val RemoteInterface = definitions.getClass("java.rmi.Remote") - lazy val RemoteException = definitions.getClass("java.rmi.RemoteException").tpe + // Additional interface parents based on annotations and other cues + def newParentForAttr(attr: Symbol): Option[Type] = attr match { + case SerializableAttr => Some(SerializableClass.tpe) + case CloneableAttr => Some(JavaCloneableClass.tpe) + case RemoteAttr => Some(RemoteInterfaceClass.tpe) + case _ => None + } val versionPickle = { val vp = new PickleBuffer(new Array[Byte](16), -1, 0) @@ -317,17 +315,13 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with innerClassBuffer.clear() val name = javaName(c.symbol) - val parents = { + val superClass :: superInterfaces = { val parents0 = c.symbol.info.parents match { case Nil => List(ObjectClass.tpe) case ps => ps } - val newInterfaces = annotationInterfaces collect { - case (annot, tpe) if c.symbol hasAnnotation annot => tpe - } - parents0 ++ newInterfaces distinct + parents0 ++ c.symbol.annotations.flatMap(ann => newParentForAttr(ann.symbol)) distinct } - val superClass :: superInterfaces = parents val ifaces = superInterfaces match { case Nil => JClass.NO_INTERFACES case _ => mkArray(superInterfaces map (x => javaName(x.typeSymbol))) @@ -886,11 +880,11 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with */ private def addRemoteException(jmethod: JMethod, meth: Symbol) { val needsAnnotation = ( - !(meth.throwsAnnotations contains RemoteException) + !(meth.throwsAnnotations contains RemoteExceptionClass) && (isRemoteClass || (meth hasAnnotation RemoteAttr) && jmethod.isPublic) ) if (needsAnnotation) { - val c = Constant(RemoteException) + val c = Constant(RemoteExceptionClass.tpe) val arg = Literal(c) setType c.tpe meth.addAnnotation(ThrowsClass, arg) } |