diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 3cf8b8f25a..33f6f0d974 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -663,10 +663,16 @@ abstract class ClassfileParser { staticModule.moduleClass.sourceFile = clazz.sourceFile } } + // Methods of a java annotation class wear this annotation when they + // provide a default value. The actual value does not need to be known + // in order to compile other classes case nme.AnnotationDefaultATTR => sym.attributes = AnnotationInfo(definitions.AnnotationDefaultAttr.tpe, List(), List()) :: sym.attributes in.skip(attrLen) + // Java annotatinos present in classfiles (when the java annotation class is + // itself annotated with @Renention(RetentionPolicy.RUNTIME) or .CLASS) are + // stored in a "RuntimeVisibleAnnotation" (i.e. nme.RuntimeAnnotationATTR) case nme.RuntimeAnnotationATTR => parseAnnotations(attrLen) if (settings.debug.value) @@ -704,8 +710,8 @@ abstract class ClassfileParser { new ArrayConstant(arr.toArray, appliedType(definitions.ArrayClass.typeConstructor, List(arr(0).tpe))) case ANNOTATION_TAG => - parseAnnotation(index) // skip it - new AnnotationConstant() + val info = parseAnnotation(index) + new AnnotationConstant(info) } } @@ -713,7 +719,7 @@ abstract class ClassfileParser { * throw an exception. If it contains a nested annotation, * return None. */ - def parseAnnotation(attrNameIndex: Char): Option[AnnotationInfo] = { + def parseAnnotation(attrNameIndex: Char): /* Option[ */ AnnotationInfo /*]*/ = { val attrType = pool.getType(attrNameIndex) val nargs = in.nextChar val nvpairs = new ListBuffer[(Name,AnnotationArgument)] @@ -722,16 +728,16 @@ abstract class ClassfileParser { for (i <- 0 until nargs) { val name = pool.getName(in.nextChar) val argConst = parseTaggedConstant - if (argConst.tag == AnnotationTag) - nestedAnnot = true - else + //if (argConst.tag == AnnotationTag) + //nestedAnnot = true + //else nvpairs += ((name, new AnnotationArgument(argConst))) } - if (nestedAnnot) - None - else - Some(AnnotationInfo(attrType, List(), nvpairs.toList)) + //if (nestedAnnot) + //None + //else + AnnotationInfo(attrType, List(), nvpairs.toList) } /** Parse a sequence of annotations and attach them to the @@ -740,7 +746,7 @@ abstract class ClassfileParser { def parseAnnotations(len: Int) { val nAttr = in.nextChar for (n <- 0 until nAttr) - parseAnnotation(in.nextChar) match { +/* parseAnnotation(in.nextChar) match { case None => if (settings.debug.value) global.inform("dropping annotation on " + @@ -748,7 +754,8 @@ abstract class ClassfileParser { " that has a nested annotation") case Some(annot) => sym.attributes = annot :: sym.attributes - } + }*/ + sym.attributes = parseAnnotation(in.nextChar) :: sym.attributes } def makeInnerAlias(outer: Symbol, name: Name, iclazz: Symbol, scope: Scope): Symbol = { |