fix: do not override non-abstract stubs

This commit is contained in:
zaaarf 2023-03-28 17:37:13 +02:00
parent 8229a7b455
commit 4215780e0d
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C

View file

@ -192,10 +192,11 @@ public class JavaPoetUtils {
public static HashSet<MethodSpec> generateDummies(Collection<ExecutableElement> dummies) { public static HashSet<MethodSpec> generateDummies(Collection<ExecutableElement> dummies) {
HashSet<MethodSpec> specs = new HashSet<>(); HashSet<MethodSpec> specs = new HashSet<>();
for(ExecutableElement d : dummies) for(ExecutableElement d : dummies)
specs.add(MethodSpec.overriding(d) if(d.getModifiers().contains(Modifier.ABSTRACT))
.addStatement("throw new $T($S)", RuntimeException.class, "This is a stub and should not have been called") specs.add(MethodSpec.overriding(d)
.build() .addStatement("throw new $T($S)", RuntimeException.class, "This is a stub and should not have been called")
); .build()
);
return specs; return specs;
} }
} }