@@ -127,7 +127,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
127127 abstract class PlainSkelBuilder
128128 extends BCClassGen
129129 with BCAnnotGen
130- with JAndroidBuilder
131130 with BCForwardersGen
132131 with BCPickles
133132 with BCJGenSigGen {
@@ -140,7 +139,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
140139 var thisName : String = null // the internal name of the class being emitted
141140
142141 var claszSymbol : Symbol = null
143- var isCZParcelable = false
144142 var isCZStaticModule = false
145143
146144 // keep track of interfaces that are used in super calls, as they need to be directly inherited even if they are also indirectly inherited
@@ -167,7 +165,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
167165 assert(cnode == null , " GenBCode detected nested methods." )
168166
169167 claszSymbol = cd0.symbol
170- isCZParcelable = isAndroidParcelableClass(claszSymbol)
171168 isCZStaticModule = claszSymbol.isStaticModuleClass
172169 thisName = bTypeLoader.classBTypeFromSymbol(claszSymbol).internalName
173170
@@ -267,7 +264,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
267264 } else cd0
268265
269266 val hasStaticCtor = isCZStaticModule || cd.symbol.info.decls.exists(_.name.isStaticConstructorName)
270- if (! hasStaticCtor && isCZParcelable) fabricateStaticInitAndroid()
271267
272268 val optSerial : Option [Long ] =
273269 claszSymbol.getAnnotation(defn.SerialVersionUIDAnnot ).flatMap { annot =>
@@ -360,7 +356,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
360356 cnode.visitAttribute(if (ssa.isDefined) pickleMarkerLocal else pickleMarkerForeign)
361357 emitAnnotations(cnode, claszSymbol.annotations ++ ssa)
362358
363- if (! isCZStaticModule && ! isCZParcelable ) {
359+ if (! isCZStaticModule) {
364360 val skipStaticForwarders = (claszSymbol.is(Module ) || ctx.settings.XnoForwarders .value)
365361 if (! skipStaticForwarders) {
366362 val lmoc = claszSymbol.companionModule
@@ -381,27 +377,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
381377
382378 } // end of method initJClass
383379
384- /*
385- * must-single-thread
386- */
387- private def fabricateStaticInitAndroid ()(using Context ): Unit = {
388-
389- val clinit : asm.MethodVisitor = cnode.visitMethod(
390- asm.Opcodes .ACC_PUBLIC | asm.Opcodes .ACC_STATIC , // TODO confirm whether we really don't want ACC_SYNTHETIC nor ACC_DEPRECATED
391- CLASS_CONSTRUCTOR_NAME ,
392- " ()V" ,
393- null , // no java-generic-signature
394- null // no throwable exceptions
395- )
396- clinit.visitCode()
397-
398- legacyAddCreatorCode(clinit, cnode, thisName)
399-
400- clinit.visitInsn(asm.Opcodes .RETURN )
401- clinit.visitMaxs(0 , 0 ) // just to follow protocol, dummy arguments
402- clinit.visitEnd()
403- }
404-
405380 private def javaFieldFlags (sym : Symbol )(using Context ) = {
406381 import asm .Opcodes .*
407382 import GenBCodeOps .addFlagIf
@@ -937,8 +912,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
937912 }
938913 for (p <- params) { emitLocalVarScope(p.symbol, veryFirstProgramPoint, onePastLastProgramPoint, force = true ) }
939914 }
940-
941- if (isMethSymStaticCtor) { appendToStaticCtor() }
942915 } // end of emitNormalMethodBody()
943916
944917 lineNumber(rhs)
@@ -953,58 +926,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
953926 mnode = null
954927 } // end of method genDefDef()
955928
956- /*
957- * must-single-thread
958- *
959- * TODO document, explain interplay with `fabricateStaticInitAndroid()`
960- */
961- private def appendToStaticCtor ()(using Context ): Unit = {
962-
963- def insertBefore (
964- location : asm.tree.AbstractInsnNode ,
965- i0 : asm.tree.AbstractInsnNode ,
966- i1 : asm.tree.AbstractInsnNode ): Unit = {
967- if (i0 != null ) {
968- mnode.instructions.insertBefore(location, i0.clone(null ))
969- mnode.instructions.insertBefore(location, i1.clone(null ))
970- }
971- }
972-
973- // collect all return instructions
974- var rets : List [asm.tree.AbstractInsnNode ] = Nil
975- mnode foreachInsn { i => if (i.getOpcode() == asm.Opcodes .RETURN ) { rets ::= i } }
976- if (rets.isEmpty) { return }
977-
978- var insnParcA : asm.tree.AbstractInsnNode = null
979- var insnParcB : asm.tree.AbstractInsnNode = null
980- // android creator code
981- if (isCZParcelable) {
982- // add a static field ("CREATOR") to this class to cache android.os.Parcelable$Creator
983- val andrFieldDescr = bTypeLoader.classBTypeFromSymbol(AndroidCreatorClass ).descriptor
984- cnode.visitField(
985- asm.Opcodes .ACC_STATIC | asm.Opcodes .ACC_FINAL ,
986- " CREATOR" ,
987- andrFieldDescr,
988- null ,
989- null
990- )
991- // INVOKESTATIC CREATOR(): android.os.Parcelable$Creator; -- TODO where does this Android method come from?
992- val callee = claszSymbol.companionModule.info.member(androidFieldName).symbol
993- val jowner = bTypeLoader.classBTypeFromSymbol(callee.owner).internalName
994- val jname = callee.javaSimpleName
995- val jtype = bTypeLoader.methodBTypeFromSymbol(callee).descriptor
996- insnParcA = new asm.tree.MethodInsnNode (asm.Opcodes .INVOKESTATIC , jowner, jname, jtype, false )
997- // PUTSTATIC `thisName`.CREATOR;
998- insnParcB = new asm.tree.FieldInsnNode (asm.Opcodes .PUTSTATIC , thisName, " CREATOR" , andrFieldDescr)
999- }
1000-
1001- // insert a few instructions for initialization before each return instruction
1002- for (r <- rets) {
1003- insertBefore(r, insnParcA, insnParcB)
1004- }
1005-
1006- }
1007-
1008929 def emitLocalVarScope (sym : Symbol , start : asm.Label , end : asm.Label , force : Boolean = false ): Unit = {
1009930 val Local (tk, name, idx, isSynth) = locals(sym)
1010931 if (force || ! isSynth) {
0 commit comments