< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java

Print this page

        

@@ -46,12 +46,10 @@
 import com.sun.tools.javac.code.TypeMetadata.Entry.Kind;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Check;
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.comp.LambdaToMethod;
-import com.sun.tools.javac.jvm.ClassFile;
 import com.sun.tools.javac.util.*;
 
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;

@@ -98,10 +96,12 @@
     JCDiagnostic.Factory diags;
     List<Warner> warnStack = List.nil();
     final Name capturedName;
 
     public final Warner noWarnings;
+    private final boolean doConstantFold;
+    private final Constables constables;
 
     // <editor-fold defaultstate="collapsed" desc="Instantiating">
     public static Types instance(Context context) {
         Types instance = context.get(typesKey);
         if (instance == null)

@@ -120,10 +120,16 @@
         enter = Enter.instance(context);
         capturedName = names.fromString("<captured wildcard>");
         messages = JavacMessages.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         noWarnings = new Warner(null);
+        Options options = Options.instance(context);
+        String foldingOp = options.get("folding");
+        doConstantFold = foldingOp != null ?
+                foldingOp.equals("true") :
+                Feature.CONSTABLES.allowedInSource(source);
+        constables = Constables.instance(context);
     }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="bounds">
     /**

@@ -1319,10 +1325,13 @@
      * (iii) whose declared type is Object[];
      *  (iv) has any return type, Object signifying a polymorphic return type; and
      *   (v) is native.
     */
    public boolean isSignaturePolymorphic(MethodSymbol msym) {
+       if (doConstantFold && constables.isIntrinsicsIndy(msym)) {
+           return true;
+       }
        List<Type> argtypes = msym.type.getParameterTypes();
        return (msym.flags_field & NATIVE) != 0 &&
               (msym.owner == syms.methodHandleType.tsym || msym.owner == syms.varHandleType.tsym) &&
                argtypes.length() == 1 &&
                argtypes.head.hasTag(TypeTag.ARRAY) &&

@@ -5181,33 +5190,10 @@
             for (List<Type> ts = types; ts.nonEmpty(); ts = ts.tail) {
                 assembleSig(ts.head);
             }
         }
     }
-
-    public Type constantType(LoadableConstant c) {
-        switch (c.poolTag()) {
-            case ClassFile.CONSTANT_Class:
-                return syms.classType;
-            case ClassFile.CONSTANT_String:
-                return syms.stringType;
-            case ClassFile.CONSTANT_Integer:
-                return syms.intType;
-            case ClassFile.CONSTANT_Float:
-                return syms.floatType;
-            case ClassFile.CONSTANT_Long:
-                return syms.longType;
-            case ClassFile.CONSTANT_Double:
-                return syms.doubleType;
-            case ClassFile.CONSTANT_MethodHandle:
-                return syms.methodHandleType;
-            case ClassFile.CONSTANT_MethodType:
-                return syms.methodTypeType;
-            default:
-                throw new AssertionError("Not a loadable constant: " + c.poolTag());
-        }
-    }
     // </editor-fold>
 
     public void newRound() {
         descCache._map.clear();
         isDerivedRawCache.clear();
< prev index next >