Suspicious 'noOuterThisPath' variable in com.sun.tools.javac.comp.Attr#visitIdent
Jan Lahoda
jan.lahoda at oracle.com
Wed Aug 18 08:37:21 UTC 2021
Hi Andrey,
Thanks for the report. I believe this is a leftover from -source <= 5
removal. The original code was:
noOuterThisPath = !allowAnonOuterThis;
where allowAnonOuterThis was true for -source >= 5, and with the
removal, "!allowAnonOuterThis" was changed to always be false.
I've filled:
https://bugs.openjdk.java.net/browse/JDK-8272618
Thanks,
Jan
On 18. 08. 21 9:50, Andrey Turbanov wrote:
> Hello.
>
> During investigation of results of IDEA inspections I found suspicious
> code in a method 'com.sun.tools.javac.comp.Attr#visitIdent'
> https://github.com/openjdk/jdk/blob/master/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java#L4194
>
> Env<AttrContext> symEnv = env;
> boolean noOuterThisPath = false;
> if (env.enclClass.sym.owner.kind != PCK && // we are in an inner class
> sym.kind.matches(KindSelector.VAL_MTH) &&
> sym.owner.kind == TYP &&
> tree.name != names._this && tree.name != names._super) {
>
> // Find environment in which identifier is defined.
> while (symEnv.outer != null &&
> !sym.isMemberOf(symEnv.enclClass.sym, types)) {
> if ((symEnv.enclClass.sym.flags() & NOOUTERTHIS) != 0)
> noOuterThisPath = false;
> symEnv = symEnv.outer;
> }
> }
>
>
> Variable 'noOuterThisPath' has initially assigned a 'false' value.
> And then in cycle it again can be set to 'false'.
> There are only 2 places where noOuterThisPath is assigned.
> It seems it should be set to 'true' in one of the places.
>
>
> Andrey Turbanov
More information about the compiler-dev
mailing list