do (1) you mean the type at runtime? Or (2) simply the type of a
(Field|Method)Reference if it does not have a prefix?
(1) not at all with Recoder, as it is a framework for static analysis and
metaprogramming ;)
(2) sc.getSourceInfo().getMethod(x).getContainingClassType().
Note, before Java 5 a member reference that is not prefixed would have to come
from the current type (possibly inherited). That is NOT the case any more, due
to static imports.
/Tobias
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all!
How do I retrieve the dynamic type of a field reference?
In comparison, to retrieve the static type of FieldReference 'x' I have:
ReferencePrefix refPrefix = x.getReferencePrefix();
if (refPrefix != null) {
Type type = sc.getSourceInfo().getType(refPrefix);
}
The same question applies also for a MethodReference.
Thanks for any help or hints!
Hej,
do (1) you mean the type at runtime? Or (2) simply the type of a
(Field|Method)Reference if it does not have a prefix?
(1) not at all with Recoder, as it is a framework for static analysis and
metaprogramming ;)
(2) sc.getSourceInfo().getMethod(x).getContainingClassType().
Note, before Java 5 a member reference that is not prefixed would have to come
from the current type (possibly inherited). That is NOT the case any more, due
to static imports.
/Tobias