From 9040c38992d36e5955c647c9831dc0e19d7b154e Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Thu, 17 Nov 2022 15:18:50 -0800 Subject: [PATCH] Print a better error message when attempting to bridge from void to void (#35) --- .../infradna/tool/bridge_method_injector/MethodInjector.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/injector/src/main/java/com/infradna/tool/bridge_method_injector/MethodInjector.java b/injector/src/main/java/com/infradna/tool/bridge_method_injector/MethodInjector.java index de33f77..de24970 100644 --- a/injector/src/main/java/com/infradna/tool/bridge_method_injector/MethodInjector.java +++ b/injector/src/main/java/com/infradna/tool/bridge_method_injector/MethodInjector.java @@ -231,6 +231,8 @@ public void inject(ClassVisitor cv) { if (returnType.equals(Type.VOID_TYPE) || returnType.getClassName().equals("java.lang.Void")) { // bridge to void, which means disregard the return value from the original method switch (originalReturnType.getSize()) { + case 0: + throw new IllegalArgumentException("Cannot bridge " + name + " from void to void; did you mean to use a different type?"); case 1: mv.visitInsn(POP); break;