|
Eclipse JDT Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A method binding represents a method or constructor of a class or interface.
Method bindings usually correspond directly to method or
constructor declarations found in the source code.
However, in certain cases of references to a generic method,
the method binding may correspond to a copy of a generic method
declaration with substitutions for the method's type parameters
(for these, getTypeArguments
returns a non-empty
list, and either isParameterizedMethod
or
isRawMethod
returns true
).
And in certain cases of references to a method declared in a
generic type, the method binding may correspond to a copy of a
method declaration with substitutions for the type's type
parameters (for these, getTypeArguments
returns
an empty list, and both isParameterizedMethod
and
isRawMethod
return false
).
This interface is not intended to be implemented by clients.
ITypeBinding.getDeclaredMethods()
Field Summary |
---|
Fields inherited from interface org.eclipse.jdt.core.dom.IBinding |
---|
METHOD, PACKAGE, TYPE, VARIABLE |
Method Summary | |
---|---|
ITypeBinding |
getDeclaringClass()
Returns the type binding representing the class or interface that declares this method or constructor. |
ITypeBinding[] |
getExceptionTypes()
Returns a list of type bindings representing the types of the exceptions thrown by this method or constructor. |
IMethodBinding |
getMethodDeclaration()
Returns the binding for the method declaration corresponding to this method binding. |
String |
getName()
Returns the name of the method declared in this binding. |
ITypeBinding[] |
getParameterTypes()
Returns a list of type bindings representing the formal parameter types, in declaration order, of this method or constructor. |
ITypeBinding |
getReturnType()
Returns the binding for the return type of this method. |
ITypeBinding[] |
getTypeArguments()
Returns the type arguments of this generic method instance, or the empty list for other method bindings. |
ITypeBinding[] |
getTypeParameters()
Returns the type parameters of this method or constructor binding. |
boolean |
isConstructor()
Returns whether this binding is for a constructor or a method. |
boolean |
isDefaultConstructor()
Returns whether this binding is known to be a compiler-generated default constructor. |
boolean |
isGenericMethod()
Returns whether this method binding represents a declaration of a generic method. |
boolean |
isParameterizedMethod()
Returns whether this method binding represents an instance of a generic method corresponding to a parameterized method reference. |
boolean |
isRawMethod()
Returns whether this method binding represents an instance of a generic method corresponding to a raw method reference. |
boolean |
isSubsignature(IMethodBinding otherMethod)
Returns whether this method's signature is a subsignature of the given method as specified in section 8.4.2 of The Java Language Specification, Third Edition (JLS3). |
boolean |
isVarargs()
Returns whether this is a variable arity method. |
boolean |
overrides(IMethodBinding method)
Returns whether this method overrides the given method, as specified in section 6.4.2 of The Java Language Specification, Second Edition (JLS2). |
Methods inherited from interface org.eclipse.jdt.core.dom.IBinding |
---|
equals, getJavaElement, getKey, getKind, getModifiers, isDeprecated, isEqualTo, isSynthetic, toString |
Method Detail |
public boolean isConstructor()
true
if this is the binding for a constructor,
and false
if this is the binding for a methodpublic boolean isDefaultConstructor()
This method returns false
for:
true
if this is known to be the binding for a
compiler-generated default constructor, and false
otherwisepublic String getName()
getName
in interface IBinding
public ITypeBinding getDeclaringClass()
public ITypeBinding[] getParameterTypes()
Note that the binding for the last parameter type of a vararg method
declaration like void fun(Foo... args)
is always for
an array type (i.e., Foo[]
) reflecting the the way varargs
get compiled. However, the type binding obtained directly from
the SingleVariableDeclaration
for the vararg parameter
is always for the type as written; i.e., the type binding for
Foo
.
Note: The result does not include synthetic parameters introduced by inner class emulation.
public ITypeBinding getReturnType()
void
return type for constructors.
void
return type for constructorspublic ITypeBinding[] getExceptionTypes()
public ITypeBinding[] getTypeParameters()
Note that type parameters only occur on the binding of the declaring generic method. Type bindings corresponding to a raw or parameterized reference to a generic method do not carry type parameters (they instead have non-empty type arguments and non-trivial erasure).
ITypeBinding.isTypeVariable()
public boolean isGenericMethod()
Note that type parameters only occur on the binding of the
declaring generic method; e.g., public <T> T identity(T t);
.
Method bindings corresponding to a raw or parameterized reference to a generic
method do not carry type parameters (they instead have non-empty type arguments
and non-trivial erasure).
This method is fully equivalent to getTypeParameters().length > 0)
.
Note that isGenericMethod()
,
isParameterizedMethod()
,
and isRawMethod()
are mutually exclusive.
true
if this method binding represents a
declaration of a generic method, and false
otherwisegetTypeParameters()
public boolean isParameterizedMethod()
Note that isGenericMethod()
,
isParameterizedMethod()
,
and isRawMethod()
are mutually exclusive.
true
if this method binding represents a
an instance of a generic method corresponding to a parameterized
method reference, and false
otherwisegetMethodDeclaration()
,
getTypeArguments()
public ITypeBinding[] getTypeArguments()
Note that type arguments only occur on a method binding that represents an instance of a generic method corresponding to a raw or parameterized reference to a generic method. Do not confuse these with type parameters which only occur on the method binding corresponding directly to the declaration of a generic method.
getMethodDeclaration()
,
isParameterizedMethod()
,
isRawMethod()
public IMethodBinding getMethodDeclaration()
isParameterizedMethod()
)
and raw methods (isRawMethod()
), this method returns the binding
for the corresponding generic method. For other method bindings, this
returns the same binding.
Note: The one notable exception is the method Object.getClass()
,
which is declared to return Class<? extends Object>
, but
when invoked its return type becomes Class<? extends
R>
, where R is the compile type of
the receiver of the method invocation.
public boolean isRawMethod()
Note that isGenericMethod()
,
isParameterizedMethod()
,
and isRawMethod()
are mutually exclusive.
true
if this method binding represents a
an instance of a generic method corresponding to a raw
method reference, and false
otherwisegetMethodDeclaration()
,
getTypeArguments()
public boolean isSubsignature(IMethodBinding otherMethod)
true
if this method's signature is a subsignature of the given methodpublic boolean isVarargs()
Note: Variable arity ("varargs") methods were added in JLS3.
true
if this is a variable arity method,
and false
otherwisepublic boolean overrides(IMethodBinding method)
method
- the method that is possibly overriden
true
if this method overrides the given method,
and false
otherwise
|
Eclipse JDT Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |