}
}
static Method getFromNativeMethod(FromNativeType fromNativeType, AsmClassLoader classLoader) {
FromNativeConverter fromNativeConverter = fromNativeType.getFromNativeConverter();
if (fromNativeConverter == null) {
return null;
}
try {
Class<? extends FromNativeConverter> fromNativeConverterClass = fromNativeConverter.getClass();
if (Modifier.isPublic(fromNativeConverterClass.getModifiers())) {
for (Method method : fromNativeConverterClass.getMethods()) {
if (!method.getName().equals("fromNative")) continue;
Class[] methodParameterTypes = method.getParameterTypes();
Class javaType = fromNativeType.getDeclaredType().isPrimitive()
? boxedType(fromNativeType.getDeclaredType())
: fromNativeType.getDeclaredType();
if (javaType.isAssignableFrom(method.getReturnType())
&& methodParameterTypes.length == 2
&& methodParameterTypes[0].isAssignableFrom(fromNativeConverter.nativeType())
&& methodParameterTypes[1] == FromNativeContext.class
&& methodIsAccessible(method)
&& classIsVisible(classLoader, method.getDeclaringClass())) {
return method;
}