diff -r f1fbe29e36d1 -r b06c2db45ddb src/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Mon May 12 09:53:35 2014 -0700 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue May 13 14:18:34 2014 +0100 @@ -82,6 +82,7 @@ private final TreeInfo treeinfo; private final JavaFileManager fileManager; private final Profile profile; + private final boolean warnOnAccessToSensitiveMembers; // The set of lint options currently in effect. It is initialized // from the context, and then is set/reset as needed by Attr as it @@ -131,6 +132,7 @@ warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); enableSunApiLintControl = options.isSet("enableSunApiLintControl"); + warnOnAccessToSensitiveMembers = options.isSet("warnOnAccessToSensitiveMembers"); Target target = Target.instance(context); syntheticNameChar = target.syntheticNameChar(); @@ -2588,6 +2590,44 @@ } } + void checkElemAccessFromSerializableLambda(final JCTree tree) { + if (warnOnAccessToSensitiveMembers) { + Symbol sym = TreeInfo.symbol(tree); + if ((sym.kind & (VAR | MTH)) == 0) { + return; + } + + if (sym.kind == VAR) { + if ((sym.flags() & PARAMETER) != 0 || + sym.isLocal() || + sym.name == names._this || + sym.name == names._super) { + return; + } + } + + if (!types.isSubtype(sym.owner.type, syms.serializableType) && + isEffectivelyNonPublic(sym)) { + log.warning(tree.pos(), + "access.to.sensitive.member.from.serializable.element", sym); + } + } + } + + private boolean isEffectivelyNonPublic(Symbol sym) { + if (sym.packge() == syms.rootPackage) { + return false; + } + + while (sym.kind != Kinds.PCK) { + if ((sym.flags() & PUBLIC) == 0) { + return true; + } + sym = sym.owner; + } + return false; + } + /** Report a conflict between a user symbol and a synthetic symbol. */ private void syntheticError(DiagnosticPosition pos, Symbol sym) {