Bug 39664 - setSuperInterfaces(String[] interfaceNames) API of org.eclipse.jdt.core.jdom.IDOMType interface does not work for an empty array parameter as Input
Summary: setSuperInterfaces(String[] interfaceNames) API of org.eclipse.jdt.core.jdom...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 critical (vote)
Target Milestone: 2.1.2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-05 08:17 EDT by Vijayan CLA
Modified: 2003-10-23 06:42 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vijayan CLA 2003-07-05 08:17:25 EDT
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.
Comment 1 Olivier Thomann CLA 2003-07-07 12:09:03 EDT
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.
Comment 2 Vijayan CLA 2003-07-08 08:31:08 EDT
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();
	}
}
Comment 3 Olivier Thomann CLA 2003-07-08 11:57:20 EDT
Fixed and released in HEAD.
Regression test added.
Comment 4 Olivier Thomann CLA 2003-07-08 11:59:11 EDT
Changed milestone.
Comment 5 Vijayan CLA 2003-07-14 10:54:18 EDT
Can a patch be released for the same for Eclipse Version 2.1.0/2.1.1 ?
Comment 6 David Audel CLA 2003-07-16 04:12:35 EDT
Verified.
Comment 7 Olivier Thomann CLA 2003-07-16 12:20:14 EDT
Backported to 2.1. maintenance stream.
Comment 8 Olivier Thomann CLA 2003-07-16 12:21:20 EDT
Regression test added.
Comment 9 Philipe Mulet CLA 2003-09-04 12:44:10 EDT
Candidate for 2.1.2
Comment 10 Frederic Fusier CLA 2003-10-17 06:31:04 EDT
Test case verified with build 2.1.2 RC1
Comment 11 Jerome Lanneluc CLA 2003-10-23 06:42:51 EDT
Test case verified with build 2.1.2 RC2