Summary: | Public flag not set for interface method | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Randy Giffen <ragiffen> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | akiezun |
Version: | 2.0.1 | ||
Target Milestone: | 2.1 M3 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Randy Giffen
2002-10-08 11:37:15 EDT
It depends whether you look at the AST or the resolved binding for the method. The AST itself only reflects syntactical information on it (if code did specify 'public', then yes it would answer it is public). The binding is doing all inference, based on the context. I'm dealing with an IType so I assume it is not easy to obtain a resolved binding for the method? Ok I see. The JavaModel is only surfacing the information found in the source in a digested way (parsed text). No inference is performed (propagating flags from enclosing contexts). We could add some new API to do so though. How critical is this for you ? In our situation we need to know if a method is public. We could change our code from int flags = method.getFlags(); return Flags.isPublic(flags) to int flags = method.getFlags(); return (Flags.isPublic(flags) || method.getDeclaringType().isInterface()) However I filed this bug because after reading the API Javadoc I thought the behavior was incorrect. So perhaps the doc should be clarified. Randy, have a look at our (jdt ui) JdtFlags class - we had the same problem and that class is a solution for it. Clarified spec as follows: ** * Returns the modifier flags for this member. The flags can be examined using class * <code>Flags</code>. * <p> * Note that only flags as indicated in the source are returned. Thus if an interface * defines a method <code>void myMethod();</code> the flags don't include the * 'public' flag. * * @exception JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource. * @return the modifier flags for this member * @see Flags */ int getFlags() throws JavaModelException; Verified. |