--- old/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java 2017-07-20 16:21:08.042893122 +0300 +++ new/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java 2017-07-20 16:21:07.986894965 +0300 @@ -2050,15 +2050,30 @@ } break; case CAPTURED_OUTER_THIS: - if (lambdaIdent.sym.owner.kind == TYP && m.containsKey(lambdaIdent.sym.owner)) { - // Transform outer instance variable references anchoring them to the captured synthetic. - Symbol tSym = m.get(lambdaIdent.sym.owner); - JCExpression t = make.Ident(tSym).setType(lambdaIdent.sym.owner.type); - tSym.setTypeAttributes(lambdaIdent.sym.owner.getRawTypeAttributes()); - t = make.Select(t, lambdaIdent.name); - t.setType(lambdaIdent.type); - TreeInfo.setSymbol(t, lambdaIdent.sym); - return t; + if (lambdaIdent.sym.owner.kind == TYP) { + Symbol tSym = null; + found_proxy: for (Symbol out:m.keySet()) { + Symbol p = out; + while (true) { + if (lambdaIdent.sym.owner.equals(p)) { + tSym = m.get(out); + break found_proxy; + } + Type t2 = ((Symbol.ClassSymbol)p).getSuperclass(); + if (!t2.hasTag(CLASS) || t2.isErroneous()) + break; + p = t2.tsym; + } + } + if (tSym != null) { + // Transform outer instance variable references anchoring them to the captured synthetic. + JCExpression t = make.Ident(tSym).setType(lambdaIdent.sym.owner.type); + tSym.setTypeAttributes(lambdaIdent.sym.owner.getRawTypeAttributes()); + t = make.Select(t, lambdaIdent.name); + t.setType(lambdaIdent.type); + TreeInfo.setSymbol(t, lambdaIdent.sym); + return t; + } } break; }