From 1c53db1450fb423a0e864aab920c9ad5a0867c42 Mon Sep 17 00:00:00 2001 From: Rafael Winterhalter Date: Fri, 10 Dec 2021 21:46:26 +0100 Subject: [PATCH] Make sure interface types are initialized before inline mocking to avoid blocking code of static initializers. --- .../internal/creation/bytebuddy/InlineBytecodeGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java index 077bf9780d..10b73c81a2 100644 --- a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java +++ b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineBytecodeGenerator.java @@ -252,8 +252,8 @@ private void triggerRetransformation(Set> types, boolean flat) { } else { do { if (mocked.add(type)) { - assureInitialization(type); if (!flatMocked.remove(type)) { + assureInitialization(type); targets.add(type); } addInterfaces(targets, type.getInterfaces()); @@ -356,6 +356,7 @@ private void addInterfaces(Set> types, Class[] interfaces) { for (Class type : interfaces) { if (mocked.add(type)) { if (!flatMocked.remove(type)) { + assureInitialization(type); types.add(type); } addInterfaces(types, type.getInterfaces());