langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 5736 ee0850472ca1
parent 5321 c8efe769cb3b
child 5738 c24b113fe4ac
equal deleted inserted replaced
5371:ff9031a745d9 5736:ee0850472ca1
   120         allowStringsInSwitch = source.allowStringsInSwitch();
   120         allowStringsInSwitch = source.allowStringsInSwitch();
   121         sourceName = source.name;
   121         sourceName = source.name;
   122         relax = (options.get("-retrofit") != null ||
   122         relax = (options.get("-retrofit") != null ||
   123                  options.get("-relax") != null);
   123                  options.get("-relax") != null);
   124         useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null;
   124         useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null;
   125         allowInvokedynamic = options.get("invokedynamic") != null;
       
   126         enableSunApiLintControl = options.get("enableSunApiLintControl") != null;
   125         enableSunApiLintControl = options.get("enableSunApiLintControl") != null;
   127     }
   126     }
   128 
   127 
   129     /** Switch: relax some constraints for retrofit mode.
   128     /** Switch: relax some constraints for retrofit mode.
   130      */
   129      */
   152 
   151 
   153     /** Switch: allow references to surrounding object from anonymous
   152     /** Switch: allow references to surrounding object from anonymous
   154      * objects during constructor call?
   153      * objects during constructor call?
   155      */
   154      */
   156     boolean allowAnonOuterThis;
   155     boolean allowAnonOuterThis;
   157 
       
   158     /** Switch: allow invokedynamic syntax
       
   159      */
       
   160     boolean allowInvokedynamic;
       
   161 
   156 
   162     /**
   157     /**
   163      * Switch: warn about use of variable before declaration?
   158      * Switch: warn about use of variable before declaration?
   164      * RFE: 6425594
   159      * RFE: 6425594
   165      */
   160      */
  1375             }
  1370             }
  1376 
  1371 
  1377             // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
  1372             // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
  1378             // has type <T>, and T can be a primitive type.
  1373             // has type <T>, and T can be a primitive type.
  1379             if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) {
  1374             if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) {
  1380               Type selt = ((JCFieldAccess) tree.meth).selected.type;
  1375               JCFieldAccess mfield = (JCFieldAccess) tree.meth;
  1381               if ((selt == syms.methodHandleType && methName == names.invoke) || selt == syms.invokeDynamicType) {
  1376               if ((mfield.selected.type.tsym != null &&
       
  1377                    (mfield.selected.type.tsym.flags() & POLYMORPHIC_SIGNATURE) != 0)
       
  1378                   ||
       
  1379                   (mfield.sym != null &&
       
  1380                    (mfield.sym.flags() & POLYMORPHIC_SIGNATURE) != 0)) {
  1382                   assert types.isSameType(restype, typeargtypes.head) : mtype;
  1381                   assert types.isSameType(restype, typeargtypes.head) : mtype;
       
  1382                   assert mfield.selected.type == syms.methodHandleType
       
  1383                       || mfield.selected.type == syms.invokeDynamicType;
  1383                   typeargtypesNonRefOK = true;
  1384                   typeargtypesNonRefOK = true;
  1384               }
  1385               }
  1385             }
  1386             }
  1386 
  1387 
  1387             if (!typeargtypesNonRefOK) {
  1388             if (!typeargtypesNonRefOK) {