Community
Participate
Working Groups
As per the documentation of IDOMType Interface the setSuperInterfaces(String[] interfaceNames)API should remove all the implemented interfaces from the Class definition when an empty array parameter is passed as the input . But it is not doing so.
In fact the bug is in getSuperInterfaces() that returns null when an empty array has been used to set the super interfaces in setSuperInterfaces(). It must return an empty array.
In fact I tested it for the class which implements only a single interface. It did not work when I passed the "new String[0]" as parameter. As I went through the source code of setSuperInterfaces(String[] names) in org.eclipse.jdt.internal.core.jdom.DOMType, I found that the problem maybe in the code of setSuperInterfaces itself. The method sets the fInterfaces memeber to null after validating that input parameter is an emty array parameter. Due to this the getSuperInterfaces() method returns null. Please refer to the following code for reference[This source code corresponds to org.eclipse.jdt.internal.core.jdom.DOMType of Eclipse version 2.1.0]: public void setSuperInterfaces(String[] names) { becomeDetailed(); if (names == null) { throw new IllegalArgumentException(Util.bind ("dom.nullInterfaces")); //$NON-NLS-1$ } fragment(); fSuperInterfaces= names; if (names == null || names.length == 0) { fInterfaces= null; fSuperInterfaces= null; setMask(MASK_TYPE_HAS_INTERFACES, false); } else { setMask(MASK_TYPE_HAS_INTERFACES, true); CharArrayBuffer buffer = new CharArrayBuffer(); for (int i = 0; i < names.length; i++) { if (i > 0) { buffer.append(", "); //$NON-NLS-1$ } buffer.append(names[i]); } fInterfaces = buffer.getContents(); } }
Fixed and released in HEAD. Regression test added.
Changed milestone.
Can a patch be released for the same for Eclipse Version 2.1.0/2.1.1 ?
Verified.
Backported to 2.1. maintenance stream.
Regression test added.
Candidate for 2.1.2
Test case verified with build 2.1.2 RC1
Test case verified with build 2.1.2 RC2