src/share/classes/com/sun/tools/javac/comp/Check.java

changeset 2390
b06c2db45ddb
parent 2384
327122b01a9e
child 2400
0e026d3f2786
equal deleted inserted replaced
2389:f1fbe29e36d1 2390:b06c2db45ddb
80 private boolean suppressAbortOnBadClassFile; 80 private boolean suppressAbortOnBadClassFile;
81 private boolean enableSunApiLintControl; 81 private boolean enableSunApiLintControl;
82 private final TreeInfo treeinfo; 82 private final TreeInfo treeinfo;
83 private final JavaFileManager fileManager; 83 private final JavaFileManager fileManager;
84 private final Profile profile; 84 private final Profile profile;
85 private final boolean warnOnAccessToSensitiveMembers;
85 86
86 // The set of lint options currently in effect. It is initialized 87 // The set of lint options currently in effect. It is initialized
87 // from the context, and then is set/reset as needed by Attr as it 88 // from the context, and then is set/reset as needed by Attr as it
88 // visits all the various parts of the trees during attribution. 89 // visits all the various parts of the trees during attribution.
89 private Lint lint; 90 private Lint lint;
129 allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); 130 allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
130 complexInference = options.isSet("complexinference"); 131 complexInference = options.isSet("complexinference");
131 warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); 132 warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
132 suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); 133 suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
133 enableSunApiLintControl = options.isSet("enableSunApiLintControl"); 134 enableSunApiLintControl = options.isSet("enableSunApiLintControl");
135 warnOnAccessToSensitiveMembers = options.isSet("warnOnAccessToSensitiveMembers");
134 136
135 Target target = Target.instance(context); 137 Target target = Target.instance(context);
136 syntheticNameChar = target.syntheticNameChar(); 138 syntheticNameChar = target.syntheticNameChar();
137 139
138 profile = Profile.instance(context); 140 profile = Profile.instance(context);
2586 return; 2588 return;
2587 } 2589 }
2588 } 2590 }
2589 } 2591 }
2590 2592
2593 void checkElemAccessFromSerializableLambda(final JCTree tree) {
2594 if (warnOnAccessToSensitiveMembers) {
2595 Symbol sym = TreeInfo.symbol(tree);
2596 if ((sym.kind & (VAR | MTH)) == 0) {
2597 return;
2598 }
2599
2600 if (sym.kind == VAR) {
2601 if ((sym.flags() & PARAMETER) != 0 ||
2602 sym.isLocal() ||
2603 sym.name == names._this ||
2604 sym.name == names._super) {
2605 return;
2606 }
2607 }
2608
2609 if (!types.isSubtype(sym.owner.type, syms.serializableType) &&
2610 isEffectivelyNonPublic(sym)) {
2611 log.warning(tree.pos(),
2612 "access.to.sensitive.member.from.serializable.element", sym);
2613 }
2614 }
2615 }
2616
2617 private boolean isEffectivelyNonPublic(Symbol sym) {
2618 if (sym.packge() == syms.rootPackage) {
2619 return false;
2620 }
2621
2622 while (sym.kind != Kinds.PCK) {
2623 if ((sym.flags() & PUBLIC) == 0) {
2624 return true;
2625 }
2626 sym = sym.owner;
2627 }
2628 return false;
2629 }
2630
2591 /** Report a conflict between a user symbol and a synthetic symbol. 2631 /** Report a conflict between a user symbol and a synthetic symbol.
2592 */ 2632 */
2593 private void syntheticError(DiagnosticPosition pos, Symbol sym) { 2633 private void syntheticError(DiagnosticPosition pos, Symbol sym) {
2594 if (!sym.type.isErroneous()) { 2634 if (!sym.type.isErroneous()) {
2595 if (warnOnSyntheticConflicts) { 2635 if (warnOnSyntheticConflicts) {

mercurial