### Question:
Types { public static Object asmToJdkType(Object arg, ClassLoader classLoader, MethodHandles.Lookup caller) throws Exception { if (arg instanceof Type) { Type type = (Type) arg; if (type.getSort() == Type.METHOD) { return toMethodType(type, classLoader); } else if (type.getSort() == Type.OBJECT) { return toClass(type, classLoader); } else { throw new IllegalArgumentException("Unsupported type: " + type); } } else if (arg instanceof Handle) { return toMethodHandle((Handle) arg, classLoader, caller); } else { return arg; } }  static Object asmToJdkType(Object arg, ClassLoader classLoader, MethodHandles.Lookup caller); static MethodType toMethodType(Type type, ClassLoader classLoader); static MethodHandle toMethodHandle(Handle handle, ClassLoader classLoader, MethodHandles.Lookup lookup); static String changeReturnType(Type returnType, String methodDescriptor); static String prependArgumentType(Type argumentType, String methodDescriptor);  }### Answer:
@Test public void asmToJdkType_MethodType() throws Exception { Type input = Type.getMethodType("(I)Ljava/util/function/Predicate;"); MethodType output = MethodType.methodType(Predicate.class, int.class); assertThat(asmToJdkType(input, classLoader, lookup), is(output)); }
@Test public void asmToJdkType_MethodHandle() throws Exception { Handle input = new Handle(Opcodes.H_INVOKESTATIC, "java/lang/String", "valueOf", "(I)Ljava/lang/String;", false); MethodHandle output = lookup.findStatic(String.class, "valueOf", MethodType.methodType(String.class, int.class)); assertThat(asmToJdkType(input, classLoader, lookup).toString(), is(output.toString())); }
@Test public void asmToJdkType_Class() throws Exception { Type input = Type.getType(String.class); Class<?> output = String.class; assertThat(asmToJdkType(input, classLoader, lookup), is(equalTo(output))); }
@Test public void asmToJdkType_everything_else() throws Exception { String input = "foo"; String output = input; assertThat(asmToJdkType(input, classLoader, lookup), is(output)); }