Skip to content

Commit 73ea6de

Browse files
authored
Merge pull request lampepfl#32 from dotty-staging/compact1-profile
Remove compiler dependency on @BeanInfo and @Remote
2 parents b4f9188 + fcc2053 commit 73ea6de

File tree

7 files changed

+16
-311
lines changed

7 files changed

+16
-311
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -511,120 +511,6 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
511511

512512
} // end of class JMirrorBuilder
513513

514-
/* builder of bean info classes */
515-
class JBeanInfoBuilder extends BCInnerClassGen {
516-
517-
/*
518-
* Generate a bean info class that describes the given class.
519-
*
520-
* @author Ross Judson ([email protected])
521-
*
522-
* must-single-thread
523-
*/
524-
def genBeanInfoClass(cls: Symbol, cunit: CompilationUnit, fieldSymbols: List[Symbol], methodSymbols: List[Symbol]): asm.tree.ClassNode = {
525-
526-
def javaSimpleName(s: Symbol): String = { s.javaSimpleName.toString }
527-
528-
innerClassBufferASM.clear()
529-
530-
val flags = javaFlags(cls)
531-
532-
val beanInfoName = (internalName(cls) + "BeanInfo")
533-
val beanInfoClass = new asm.tree.ClassNode
534-
beanInfoClass.visit(
535-
classfileVersion,
536-
flags,
537-
beanInfoName,
538-
null, // no java-generic-signature
539-
"scala/beans/ScalaBeanInfo",
540-
EMPTY_STRING_ARRAY
541-
)
542-
543-
beanInfoClass.visitSource(
544-
sourceFileFor(cunit).toString,
545-
null /* SourceDebugExtension */
546-
)
547-
548-
var fieldList = List[String]()
549-
550-
for (f <- fieldSymbols if f.hasGetter;
551-
g = f.getter(cls);
552-
s = f.setter(cls);
553-
if g.isPublic && !(f.name startsWith "$")
554-
) {
555-
// inserting $outer breaks the bean
556-
fieldList = javaSimpleName(f) :: javaSimpleName(g) :: (if (s != NoSymbol) javaSimpleName(s) else null) :: fieldList
557-
}
558-
559-
val methodList: List[String] =
560-
for (m <- methodSymbols
561-
if !m.isConstructor &&
562-
m.isPublic &&
563-
!(m.name startsWith "$") &&
564-
!m.isGetter &&
565-
!m.isSetter)
566-
yield javaSimpleName(m)
567-
568-
val constructor = beanInfoClass.visitMethod(
569-
asm.Opcodes.ACC_PUBLIC,
570-
INSTANCE_CONSTRUCTOR_NAME,
571-
"()V",
572-
null, // no java-generic-signature
573-
EMPTY_STRING_ARRAY // no throwable exceptions
574-
)
575-
576-
val stringArrayJType: BType = ArrayBType(StringRef)
577-
val conJType: BType = MethodBType(
578-
classBTypeFromSymbol(ClassClass) :: stringArrayJType :: stringArrayJType :: Nil,
579-
UNIT
580-
)
581-
582-
def push(lst: List[String]): Unit = {
583-
var fi = 0
584-
for (f <- lst) {
585-
constructor.visitInsn(asm.Opcodes.DUP)
586-
constructor.visitLdcInsn(new java.lang.Integer(fi))
587-
if (f == null) { constructor.visitInsn(asm.Opcodes.ACONST_NULL) }
588-
else { constructor.visitLdcInsn(f) }
589-
constructor.visitInsn(StringRef.typedOpcode(asm.Opcodes.IASTORE))
590-
fi += 1
591-
}
592-
}
593-
594-
constructor.visitCode()
595-
596-
constructor.visitVarInsn(asm.Opcodes.ALOAD, 0)
597-
// push the class
598-
constructor.visitLdcInsn(classBTypeFromSymbol(cls).toASMType)
599-
600-
// push the string array of field information
601-
constructor.visitLdcInsn(new java.lang.Integer(fieldList.length))
602-
constructor.visitTypeInsn(asm.Opcodes.ANEWARRAY, StringRef.internalName)
603-
push(fieldList)
604-
605-
// push the string array of method information
606-
constructor.visitLdcInsn(new java.lang.Integer(methodList.length))
607-
constructor.visitTypeInsn(asm.Opcodes.ANEWARRAY, StringRef.internalName)
608-
push(methodList)
609-
610-
// invoke the superclass constructor, which will do the
611-
// necessary java reflection and create Method objects.
612-
constructor.visitMethodInsn(asm.Opcodes.INVOKESPECIAL, "scala/beans/ScalaBeanInfo", INSTANCE_CONSTRUCTOR_NAME, conJType.descriptor, false)
613-
constructor.visitInsn(asm.Opcodes.RETURN)
614-
615-
constructor.visitMaxs(0, 0) // just to follow protocol, dummy arguments
616-
constructor.visitEnd()
617-
618-
innerClassBufferASM ++= classBTypeFromSymbol(cls).info.memberClasses
619-
addInnerClassesASM(beanInfoClass, innerClassBufferASM.toList)
620-
621-
beanInfoClass.visitEnd()
622-
623-
beanInfoClass
624-
}
625-
626-
} // end of class JBeanInfoBuilder
627-
628514
trait JAndroidBuilder {
629515
self: BCInnerClassGen =>
630516

src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ abstract class BTypes {
559559
* Mirror Classes
560560
* --------------
561561
*
562-
* TODO: innerclass attributes on mirror class, bean info class
562+
* TODO: innerclass attributes on mirror class
563563
*/
564564

565565
/**

src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,6 @@ class BTypesFromSymbols[I <: BackendInterface](val int: I) extends BTypes {
179179
}
180180
}
181181

182-
// legacy, to be removed when the @remote annotation gets removed
183-
final def hasPublicBitSet(flags: Int) = ((flags & asm.Opcodes.ACC_PUBLIC) != 0)
184-
185182
/**
186183
* Return the Java modifiers for the given symbol.
187184
* Java modifiers for classes:

src/compiler/scala/tools/nsc/backend/jvm/BackendInterface.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ abstract class BackendInterface extends BackendInterfaceDefinitions {
457457
def hasPackageFlag: Boolean
458458
def isImplClass: Boolean
459459
def isInterface: Boolean
460-
def hasGetter: Boolean
461460
def isGetter: Boolean
462461
def isSetter: Boolean
463462
def isGetClass: Boolean
@@ -558,7 +557,6 @@ abstract class BackendInterface extends BackendInterfaceDefinitions {
558557
def isOriginallyStaticOwner: Boolean
559558

560559

561-
def addRemoteRemoteExceptionAnnotation: Unit
562560
def samMethod(): Symbol
563561
}
564562

@@ -710,7 +708,6 @@ abstract class BackendInterfaceDefinitions { self: BackendInterface =>
710708
val BoxedFloatClass: Symbol = requiredClass[java.lang.Float]
711709
val BoxedDoubleClass: Symbol = requiredClass[java.lang.Double]
712710
val StringClass: Symbol = requiredClass[java.lang.String]
713-
val StringBuilderClass: Symbol = requiredClass[scala.collection.mutable.StringBuilder]
714711
val JavaStringBuilderClass: Symbol = requiredClass[java.lang.StringBuilder]
715712
val JavaStringBufferClass: Symbol = requiredClass[java.lang.StringBuffer]
716713
val JavaCharSequenceClass: Symbol = requiredClass[java.lang.CharSequence]
@@ -723,7 +720,6 @@ abstract class BackendInterfaceDefinitions { self: BackendInterface =>
723720

724721
val ClassfileAnnotationClass: Symbol = requiredClass[scala.annotation.ClassfileAnnotation]
725722
val BoxedNumberClass: Symbol = requiredClass[java.lang.Number]
726-
val RemoteExceptionClass: Symbol = requiredClass[java.rmi.RemoteException]
727723
val ThrowsClass: Symbol = requiredClass[scala.throws[_]]
728724

729725
// Module symbols used in backend

0 commit comments

Comments
 (0)