diff options
author | Lex Spoon <lex@lexspoon.org> | 2007-10-02 16:53:57 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2007-10-02 16:53:57 +0000 |
commit | 0b00cb9fc3ca6f186157703073e0432857b0e7cb (patch) | |
tree | f8ed838969b099ab3321c99ce401e5b657bdde09 /src | |
parent | 2f38118b94c516746ca4c1ecd723fe47bd5357ac (diff) | |
download | scala-0b00cb9fc3ca6f186157703073e0432857b0e7cb.tar.gz scala-0b00cb9fc3ca6f186157703073e0432857b0e7cb.tar.bz2 scala-0b00cb9fc3ca6f186157703073e0432857b0e7cb.zip |
do not emit attributes unless they came from Ja...
do not emit attributes unless they came from Java code
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index fbb6260f63..da9a38eef7 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -226,6 +226,13 @@ abstract class GenJVM extends SubComponent { addAttribute(jmethod, nme.ExceptionsATTR, buf) } + /** Whether an annotation should be emitted as a Java annotation */ + private def shouldEmitAttribute(annot: AnnotationInfo) = + (annot.atp.typeSymbol.hasFlag(Flags.JAVA) && + annot.atp.typeSymbol.isNonBottomSubClass(definitions.ClassfileAnnotationClass) && + annot.isConstant) + + private def emitAttributes(buf: ByteBuffer, attributes: List[AnnotationInfo]): Int = { val cpool = jclass.getConstantPool() @@ -278,9 +285,9 @@ abstract class GenJVM extends SubComponent { buf.putShort(0xbaba.toShort) for (attrib@AnnotationInfo(typ, consts, nvPairs) <- attributes; - if attrib.isConstant; - if typ.typeSymbol isNonBottomSubClass definitions.ClassfileAnnotationClass) { - nattr = nattr + 1 + if shouldEmitAttribute(attrib)) + { + nattr = nattr + 1 val jtype = javaType(typ) buf.putShort(cpool.addUtf8(jtype.getSignature()).toShort) assert(consts.length <= 1, consts.toString) @@ -301,7 +308,7 @@ abstract class GenJVM extends SubComponent { } def addAnnotations(jmember: JMember, attributes: List[AnnotationInfo]): Unit = { - val toEmit = attributes.filter(_.isConstant) + val toEmit = attributes.filter(shouldEmitAttribute(_)) if (toEmit.isEmpty) return |