Bug 78740

Summary: IDOMType.getFlags() fails to represent interface flags correctly.
Product: [Eclipse Project] JDT Reporter: Ed Merks <Ed.Merks>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: marcelop
Version: 3.1   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Full project with test case.
none
Apply on HEAD none

Description Ed Merks CLA 2004-11-16 10:57:30 EST
This code demonstrates that calling getComment on an IDOMType will change the
flags from correctly encoding the type as being interface to incorrectly
encoding it (because during becomeDetailed() that information is lost):

package org.example.jdom;

import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.jdom.DOMFactory;
import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
import org.eclipse.jdt.core.jdom.IDOMType;

public class Test implements IPlatformRunnable
{
  public Object run(Object object)
  {
    DOMFactory factory = new DOMFactory();
    IDOMCompilationUnit jCompilationUnit =
factory.createCompilationUnit("package x; /** @model */ interface X  {}", "NAME");
    IDOMType jType = (IDOMType)jCompilationUnit.getFirstChild().getNextNode(); 
    System.err.println("" + ((jType.getFlags() & Flags.AccInterface) != 0));
    jType.getComment();
    System.err.println("" + ((jType.getFlags() & Flags.AccInterface) != 0));
    return new Integer(0);
  }
}

This bug completely breaks EMF's JavaEcoreBuilder, which is a blocking problem
for our clients and hence we see this as a blocking problem.
Comment 1 Ed Merks CLA 2004-11-16 10:59:42 EST
Created attachment 15897 [details]
Full project with test case.

The attachment is a zip of the complete project for reproducing the problem.
Comment 2 Olivier Thomann CLA 2004-11-16 14:58:08 EST
I will investigate.
Comment 3 Philipe Mulet CLA 2004-11-16 16:51:22 EST
Should we consider for 3.0 maintenance backporting or is it only a blocker in
3.1 stream ?
Comment 4 Olivier Thomann CLA 2004-11-16 17:09:00 EST
This seems to be a problem only in 3.1 where the call to
adjustInterfaceModifiers(); has been removed. The DocumentElementParser has not
been updated. Fixing this resolves this issue.
I will attach a patch soon.
Comment 5 Olivier Thomann CLA 2004-11-16 17:42:50 EST
The next nightly build will contain the fix.
Comment 6 Olivier Thomann CLA 2004-11-16 17:43:41 EST
Created attachment 15909 [details]
Apply on HEAD

This will be released as soon as all tests passed.
Comment 7 Olivier Thomann CLA 2004-11-16 17:59:22 EST
Fixed and released in HEAD.
Regression test added in ASTConverterTestAST3_2.test0576
Comment 8 Ed Merks CLA 2004-11-17 07:01:22 EST
Thanks for the speedy service!!!
Comment 9 Jerome Lanneluc CLA 2004-12-14 10:00:36 EST
Verified (in I200412140010) that the test ensures that getComment() has no side
effect on the flags.