MIDL2021 Duplicate ID when use MIDL compile java2com generated IDL
You may get the following error when use midl.exe compile idl file generated by J-Integra java2com tool.
These midl error occur because of nested classes/interfaces. Notice that, in this case, java.io.PrintWriter extends java.io.Writer which in turn implements java.lang.Appendable. Therefore, the java2com tool generates an interface for each of java.io.PrintWriter, java.io.Writer, and java.lang.Appendable.
Because the COM IDL language does not know anything about Java inheritance, it generates 3 append method signatures for JavaLangAppendable, 6 append method signatures for JavaIoWriter, and 9 append method signatures for JavaIoPrintWriter. However, because of the Java inheritance involved, it ends up giving the same method id to the same append method signatures.
To resolve these errors, you need to use the Name Mappings option to tell java2com not to generate IDL definitions for the append() methods in java.io.Writer, and java.lang.Appendable:
- Run the java2com (gui) tool.
- Click Settings > Name Mappings.
- On the left-hand side, click java > io > PrintWriter (its methods will appear to the right).
- On the right-hand side, deselect the checkboxes beside the last 6 append methods.
- Save settings and regenerate the proxies.
For more informaiton about J-Integra java2com tool, please refer to online documentation:
Please also refer this documentation for using java2com in Early Binding: