When we access a field of an interface, if the field is of type long or double,
then we use pop2 to pop the value out of the stack.
RELNOTES: None
PiperOrigin-RevId: 160453904
diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java b/src/tools/android/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java
index c5bdbe7..f7621df 100644
--- a/src/tools/android/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java
+++ b/src/tools/android/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java
@@ -103,12 +103,19 @@
"Cannot get a method visitor to write out %s to the companion class.",
COMPANION_METHOD_TO_TRIGGER_INTERFACE_CLINIT_NAME);
// Visit the interface field to triger <clinit> of the interface.
+
visitor.visitFieldInsn(
Opcodes.GETSTATIC,
interfaceFieldToAccessInCompanionMethodToTriggerInterfaceClinit.owner(),
interfaceFieldToAccessInCompanionMethodToTriggerInterfaceClinit.name(),
interfaceFieldToAccessInCompanionMethodToTriggerInterfaceClinit.desc());
- visitor.visitInsn(Opcodes.POP);
+ Type fieldType =
+ Type.getType(interfaceFieldToAccessInCompanionMethodToTriggerInterfaceClinit.desc());
+ if (fieldType.getSort() == Type.LONG || fieldType.getSort() == Type.DOUBLE) {
+ visitor.visitInsn(Opcodes.POP2);
+ } else {
+ visitor.visitInsn(Opcodes.POP);
+ }
visitor.visitInsn(Opcodes.RETURN);
}