[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.jdt] Re: [Model] Bug on flags of IType

Hi

I rewrote my code and tried on a 3.4 and 3.5 Eclipse installation but i get the same results.
For a Java project with dependancies, I iterate on IClassFile of binary IPackageFragmentRoot (with no source attached).
If the contained IType is a top-level class, i do a simple Flags.isSynchronized(itype.getFlags())


It always returns true for classes with no modifiers (like the given example before).
I tried on various IPackageFragmentRoot from "JRE System Library" and also "Plug-in dependencies".


Are you sure to test on IType objects from class files ?

==test code==

public void parse(IClassFile classFile) throws JavaModelException {

IType type = classFile.getType();

//we only want top level types
if(type != null && type.exists() && !type.isAnonymous() && !type.isLocal() && !type.isMember()) {
if(type.isClass()) {
System.out.println(Flags.isSynchronized(type.getFlags()));
}
}
}


Romain

Daniel Megert a écrit :
Romain Dervaux wrote:

Hi

I am parsing IType objects from IClassFile objects.
I noticed that for classes (not interfaces), the flags are always true for the synchronized modifier.


For a simple class like that :

public class A {

}
IType#getFlags() will return 33.
Not sure what you're doing but I correctly get 1 back for that type.

Dani
IModifierConstants.ACC_SYNCHRONIZED = 32
And as 33 & 32 != 0, all classes are considered synchronized.

If a class has an another modifier like 'static', it will not have the synchronized flag.

Hope that's clear.

Romain