< prev index next >

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

Print this page

        

*** 46,57 **** 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.*; --- 46,55 ----
*** 98,107 **** --- 96,107 ---- 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,129 **** --- 120,135 ---- 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,1328 **** --- 1325,1337 ---- * (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) &&
*** 2731,2741 **** /** * Returns true iff the first signature is a <em>sub * signature</em> of the other. This is <b>not</b> an equivalence * relation. * ! * @jls 8.4.2 Method Signature * @see #overrideEquivalent(Type t, Type s) * @param t first signature (possibly raw). * @param s second signature (could be subjected to erasure). * @return true if t is a sub signature of s. */ --- 2740,2750 ---- /** * Returns true iff the first signature is a <em>sub * signature</em> of the other. This is <b>not</b> an equivalence * relation. * ! * @jls section 8.4.2. * @see #overrideEquivalent(Type t, Type s) * @param t first signature (possibly raw). * @param s second signature (could be subjected to erasure). * @return true if t is a sub signature of s. */
*** 2750,2760 **** /** * Returns true iff these signatures are related by <em>override * equivalence</em>. This is the natural extension of * isSubSignature to an equivalence relation. * ! * @jls 8.4.2 Method Signature * @see #isSubSignature(Type t, Type s) * @param t a signature (possible raw, could be subjected to * erasure). * @param s a signature (possible raw, could be subjected to * erasure). --- 2759,2769 ---- /** * Returns true iff these signatures are related by <em>override * equivalence</em>. This is the natural extension of * isSubSignature to an equivalence relation. * ! * @jls section 8.4.2. * @see #isSubSignature(Type t, Type s) * @param t a signature (possible raw, could be subjected to * erasure). * @param s a signature (possible raw, could be subjected to * erasure).
*** 4212,4222 **** return covariantReturnType(tres, sres, warner); } /** * Return-Type-Substitutable. ! * @jls 8.4.5 Method Result */ public boolean returnTypeSubstitutable(Type r1, Type r2) { if (hasSameArgs(r1, r2)) return resultSubtype(r1, r2, noWarnings); else --- 4221,4231 ---- return covariantReturnType(tres, sres, warner); } /** * Return-Type-Substitutable. ! * @jls section 8.4.5 */ public boolean returnTypeSubstitutable(Type r1, Type r2) { if (hasSameArgs(r1, r2)) return resultSubtype(r1, r2, noWarnings); else
*** 5181,5215 **** 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; - case ClassFile.CONSTANT_Dynamic: - return ((DynamicVarSymbol)c).type; - default: - throw new AssertionError("Not a loadable constant: " + c.poolTag()); - } - } // </editor-fold> public void newRound() { descCache._map.clear(); isDerivedRawCache.clear(); --- 5190,5199 ----
< prev index next >