equal
deleted
inserted
replaced
52 |
52 |
53 import static com.sun.tools.javac.code.Flags.*; |
53 import static com.sun.tools.javac.code.Flags.*; |
54 import static com.sun.tools.javac.code.Flags.ANNOTATION; |
54 import static com.sun.tools.javac.code.Flags.ANNOTATION; |
55 import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; |
55 import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; |
56 import static com.sun.tools.javac.code.Kinds.*; |
56 import static com.sun.tools.javac.code.Kinds.*; |
|
57 import static com.sun.tools.javac.code.Kinds.Kind.*; |
57 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
58 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; |
58 import static com.sun.tools.javac.code.TypeTag.*; |
59 import static com.sun.tools.javac.code.TypeTag.*; |
59 import static com.sun.tools.javac.code.TypeTag.WILDCARD; |
60 import static com.sun.tools.javac.code.TypeTag.WILDCARD; |
60 |
61 |
61 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
62 import static com.sun.tools.javac.tree.JCTree.Tag.*; |
347 */ |
348 */ |
348 void checkTransparentVar(DiagnosticPosition pos, VarSymbol v, Scope s) { |
349 void checkTransparentVar(DiagnosticPosition pos, VarSymbol v, Scope s) { |
349 for (Symbol sym : s.getSymbolsByName(v.name)) { |
350 for (Symbol sym : s.getSymbolsByName(v.name)) { |
350 if (sym.owner != v.owner) break; |
351 if (sym.owner != v.owner) break; |
351 if (sym.kind == VAR && |
352 if (sym.kind == VAR && |
352 (sym.owner.kind & (VAR | MTH)) != 0 && |
353 sym.owner.kind.matches(KindSelector.VAL_MTH) && |
353 v.name != names.error) { |
354 v.name != names.error) { |
354 duplicateError(pos, sym); |
355 duplicateError(pos, sym); |
355 return; |
356 return; |
356 } |
357 } |
357 } |
358 } |
365 */ |
366 */ |
366 void checkTransparentClass(DiagnosticPosition pos, ClassSymbol c, Scope s) { |
367 void checkTransparentClass(DiagnosticPosition pos, ClassSymbol c, Scope s) { |
367 for (Symbol sym : s.getSymbolsByName(c.name)) { |
368 for (Symbol sym : s.getSymbolsByName(c.name)) { |
368 if (sym.owner != c.owner) break; |
369 if (sym.owner != c.owner) break; |
369 if (sym.kind == TYP && !sym.type.hasTag(TYPEVAR) && |
370 if (sym.kind == TYP && !sym.type.hasTag(TYPEVAR) && |
370 (sym.owner.kind & (VAR | MTH)) != 0 && |
371 sym.owner.kind.matches(KindSelector.VAL_MTH) && |
371 c.name != names.error) { |
372 c.name != names.error) { |
372 duplicateError(pos, sym); |
373 duplicateError(pos, sym); |
373 return; |
374 return; |
374 } |
375 } |
375 } |
376 } |
2571 } |
2572 } |
2572 |
2573 |
2573 void checkElemAccessFromSerializableLambda(final JCTree tree) { |
2574 void checkElemAccessFromSerializableLambda(final JCTree tree) { |
2574 if (warnOnAccessToSensitiveMembers) { |
2575 if (warnOnAccessToSensitiveMembers) { |
2575 Symbol sym = TreeInfo.symbol(tree); |
2576 Symbol sym = TreeInfo.symbol(tree); |
2576 if ((sym.kind & (VAR | MTH)) == 0) { |
2577 if (!sym.kind.matches(KindSelector.VAL_MTH)) { |
2577 return; |
2578 return; |
2578 } |
2579 } |
2579 |
2580 |
2580 if (sym.kind == VAR) { |
2581 if (sym.kind == VAR) { |
2581 if ((sym.flags() & PARAMETER) != 0 || |
2582 if ((sym.flags() & PARAMETER) != 0 || |
2597 private boolean isEffectivelyNonPublic(Symbol sym) { |
2598 private boolean isEffectivelyNonPublic(Symbol sym) { |
2598 if (sym.packge() == syms.rootPackage) { |
2599 if (sym.packge() == syms.rootPackage) { |
2599 return false; |
2600 return false; |
2600 } |
2601 } |
2601 |
2602 |
2602 while (sym.kind != Kinds.PCK) { |
2603 while (sym.kind != PCK) { |
2603 if ((sym.flags() & PUBLIC) == 0) { |
2604 if ((sym.flags() & PUBLIC) == 0) { |
2604 return true; |
2605 return true; |
2605 } |
2606 } |
2606 sym = sym.owner; |
2607 sym = sym.owner; |
2607 } |
2608 } |
2955 private void validateDefault(Symbol container, DiagnosticPosition pos) { |
2956 private void validateDefault(Symbol container, DiagnosticPosition pos) { |
2956 // validate that all other elements of containing type has defaults |
2957 // validate that all other elements of containing type has defaults |
2957 Scope scope = container.members(); |
2958 Scope scope = container.members(); |
2958 for(Symbol elm : scope.getSymbols()) { |
2959 for(Symbol elm : scope.getSymbols()) { |
2959 if (elm.name != names.value && |
2960 if (elm.name != names.value && |
2960 elm.kind == Kinds.MTH && |
2961 elm.kind == MTH && |
2961 ((MethodSymbol)elm).defaultValue == null) { |
2962 ((MethodSymbol)elm).defaultValue == null) { |
2962 log.error(pos, |
2963 log.error(pos, |
2963 "invalid.repeatable.annotation.elem.nondefault", |
2964 "invalid.repeatable.annotation.elem.nondefault", |
2964 container, |
2965 container, |
2965 elm); |
2966 elm); |
3039 else if (target == names.FIELD) |
3040 else if (target == names.FIELD) |
3040 { if (s.kind == VAR && s.owner.kind != MTH) return true; } |
3041 { if (s.kind == VAR && s.owner.kind != MTH) return true; } |
3041 else if (target == names.METHOD) |
3042 else if (target == names.METHOD) |
3042 { if (s.kind == MTH && !s.isConstructor()) return true; } |
3043 { if (s.kind == MTH && !s.isConstructor()) return true; } |
3043 else if (target == names.PARAMETER) |
3044 else if (target == names.PARAMETER) |
3044 { if (s.kind == VAR && |
3045 { if (s.kind == VAR && s.owner.kind == MTH && |
3045 s.owner.kind == MTH && |
|
3046 (s.flags() & PARAMETER) != 0) |
3046 (s.flags() & PARAMETER) != 0) |
3047 return true; |
3047 return true; |
3048 } |
3048 } |
3049 else if (target == names.CONSTRUCTOR) |
3049 else if (target == names.CONSTRUCTOR) |
3050 { if (s.kind == MTH && s.isConstructor()) return true; } |
3050 { if (s.kind == MTH && s.isConstructor()) return true; } |
3058 return true; |
3058 return true; |
3059 } |
3059 } |
3060 else if (target == names.PACKAGE) |
3060 else if (target == names.PACKAGE) |
3061 { if (s.kind == PCK) return true; } |
3061 { if (s.kind == PCK) return true; } |
3062 else if (target == names.TYPE_USE) |
3062 else if (target == names.TYPE_USE) |
3063 { if (s.kind == TYP || |
3063 { if (s.kind == TYP || s.kind == VAR || |
3064 s.kind == VAR || |
|
3065 (s.kind == MTH && !s.isConstructor() && |
3064 (s.kind == MTH && !s.isConstructor() && |
3066 !s.type.getReturnType().hasTag(VOID)) || |
3065 !s.type.getReturnType().hasTag(VOID)) || |
3067 (s.kind == MTH && s.isConstructor())) |
3066 (s.kind == MTH && s.isConstructor())) |
3068 return true; |
3067 return true; |
3069 } |
3068 } |
3241 return; |
3240 return; |
3242 } |
3241 } |
3243 try { |
3242 try { |
3244 tsym.flags_field |= LOCKED; |
3243 tsym.flags_field |= LOCKED; |
3245 for (Symbol s : tsym.members().getSymbols(NON_RECURSIVE)) { |
3244 for (Symbol s : tsym.members().getSymbols(NON_RECURSIVE)) { |
3246 if (s.kind != Kinds.MTH) |
3245 if (s.kind != MTH) |
3247 continue; |
3246 continue; |
3248 checkAnnotationResType(pos, ((MethodSymbol)s).type.getReturnType()); |
3247 checkAnnotationResType(pos, ((MethodSymbol)s).type.getReturnType()); |
3249 } |
3248 } |
3250 } finally { |
3249 } finally { |
3251 tsym.flags_field &= ~LOCKED; |
3250 tsym.flags_field &= ~LOCKED; |