Bug 245518 - ICompilationUnit.createType failing with unexpected exception
Summary: ICompilationUnit.createType failing with unexpected exception
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-28 07:04 EDT by Jerome Lanneluc CLA
Modified: 2008-09-15 11:47 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 Jerome Lanneluc CLA 2008-08-28 07:04:32 EDT
I20080827-0935 + fix for bug 245348

With the fix for bug 245348, if you call ICompilation.createType("public @interface Annot {}") on a cu in a 1.3 project, you get a NoSuchElementException:

java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(AbstractList.java:426)
	at org.eclipse.jdt.internal.core.CreateTypeMemberOperation.generateElementAST(CreateTypeMemberOperation.java:92)
	at org.eclipse.jdt.internal.core.CreateTypeOperation.generateElementAST(CreateTypeOperation.java:43)
	at org.eclipse.jdt.internal.core.CreateTypeMemberOperation.verify(CreateTypeMemberOperation.java:200)
	at org.eclipse.jdt.internal.core.CreateTypeOperation.verify(CreateTypeOperation.java:106)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:763)
	at org.eclipse.jdt.internal.core.CompilationUnit.createType(CompilationUnit.java:449)

This exception is not specified. Instead a JavaModelException with INVALID_CONTENTS should be thrown.
Comment 1 Olivier Thomann CLA 2008-08-28 09:18:27 EDT
Released for 3.5M2.
Updated existing test.
Comment 2 Jerome Lanneluc CLA 2008-08-28 09:54:31 EDT
-1 on updating the test. The intent of the test (as explained in its Javadoc) is to ensure that a type can be created using createType(). The problem is that the cu's project has a 1.3 source level. The test should have been updated to ensure that the source level is 1.5 when testing the creation of an annotation type. And a new test should be written to ensure that this bug is fixed.
Comment 3 Olivier Thomann CLA 2008-08-28 09:58:42 EDT
The old test was boggus. So updating it to reflect the right behavior was not wrong. I can add a new test to make sure that the 1.5 case is working.
Comment 4 Jerome Lanneluc CLA 2008-08-28 10:04:06 EDT
(In reply to comment #3)
> The old test was boggus. So updating it to reflect the right behavior was not
> wrong.
Then you should have updated the test's Javadoc as well.

> I can add a new test to make sure that the 1.5 case is working.
Please do so. 

Comment 5 Olivier Thomann CLA 2008-08-28 10:17:37 EDT
Done.
Comment 6 Jerome Lanneluc CLA 2008-09-15 11:47:35 EDT
Verified for 3.5M2 using I20080914-2000