[Bug] binding-generator fails to process pointer of type parameter as template argument type with `java.lang.ClassCastException`
sighingnow opened this issue · comments
Tao He commented
The binding generator cannot handle cases where pointer types points to a type parameter. For following code
#pragma once
template <typename T>
class reverse_iterator {
};
template <class CharT>
class basic_string_view
{
public:
typedef CharT const * const_pointer;
typedef const_pointer const_iterator;
typedef reverse_iterator< const_iterator > const_reverse_iterator;
const_reverse_iterator begin() const {
return const_reverse_iterator{};
}
};
The binding generator throws an exception:
Exception in thread "main" java.lang.ClassCastException: com.squareup.javapoet.TypeVariableName cannot be cast to com.squareup.javapoet.ClassName
at com.alibaba.fastffi.tool.FFIBindingGenerator.getPointerOfPointer(FFIBindingGenerator.java:1736)
at com.alibaba.fastffi.tool.FFIBindingGenerator.lambda$getJavaTypeForTemplateSpecializationType$8(FFIBindingGenerator.java:1913)
at com.alibaba.fastffi.tool.FFIBindingGenerator.forEachTemplateArgument(FFIBindingGenerator.java:1168)
at com.alibaba.fastffi.tool.FFIBindingGenerator.getJavaTypeForTemplateSpecializationType(FFIBindingGenerator.java:1905)
at com.alibaba.fastffi.tool.FFIBindingGenerator.typeToTypeName(FFIBindingGenerator.java:1604)
at com.alibaba.fastffi.tool.FFIBindingGenerator.typeToFFIType(FFIBindingGenerator.java:1759)
at com.alibaba.fastffi.tool.FFIBindingGenerator.getJavaTypeForTypedefType(FFIBindingGenerator.java:1671)
at com.alibaba.fastffi.tool.FFIBindingGenerator.typeToTypeName(FFIBindingGenerator.java:1613)
at com.alibaba.fastffi.tool.FFIBindingGenerator.typeToFFIType(FFIBindingGenerator.java:1759)
at com.alibaba.fastffi.tool.FFIBindingGenerator.buildReturnAndParamTypes(FFIBindingGenerator.java:1532)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generateFFIPointer(FFIBindingGenerator.java:2387)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generateCXXRecord(FFIBindingGenerator.java:2079)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generate(FFIBindingGenerator.java:1312)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generateClassTemplate(FFIBindingGenerator.java:1495)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generate(FFIBindingGenerator.java:1315)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generate(FFIBindingGenerator.java:1282)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generate(FFIBindingGenerator.java:1272)
at com.alibaba.fastffi.tool.FFIBindingGenerator.generate(FFIBindingGenerator.java:1067)
at com.alibaba.fastffi.tool.FFIBindingGenerator.main(FFIBindingGenerator.java:423)