changeset 47340:cf497ae988ca condy-folding

delta applying all condy folding changes to javac in preparation for a code redesign
author vromero
date Fri, 29 Sep 2017 14:38:51 -0700
parents b91fd4d32f06
children e586e8f7b8ce
files src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstablesVisitor.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/SpecialConstantUtils.java
diffstat 31 files changed, 238 insertions(+), 1890 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Fri Sep 29 14:38:51 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -370,6 +370,11 @@
         return (symbol.flags() & ENUM) != 0;
     }
 
+    public static boolean isConstant(Symbol.VarSymbol symbol) {
+        return symbol.getConstValue() != null;
+    }
+
+
     public enum Flag {
         PUBLIC(Flags.PUBLIC),
         PRIVATE(Flags.PRIVATE),
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Fri Sep 29 14:38:51 2017 -0700
@@ -226,9 +226,6 @@
     public boolean allowUnderscoreIdentifier() {
         return compareTo(JDK1_8) <= 0;
     }
-    public boolean allowCondyForLambda() {
-        return compareTo(JDK1_10) >= 0;
-    }
     public boolean allowPrivateInterfaceMethods() { return compareTo(JDK1_9) >= 0; }
     public boolean allowLocalVariableTypeInference() { return compareTo(JDK1_10) >= 0; }
     public static SourceVersion toSourceVersion(Source source) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Sep 29 14:38:51 2017 -0700
@@ -48,13 +48,13 @@
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.ClassFinder.BadEnclosingMethodAttr;
+import com.sun.tools.javac.code.Directive.RequiresFlag;
 import com.sun.tools.javac.code.Kinds.Kind;
 import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
 import com.sun.tools.javac.code.Scope.WriteableScope;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.comp.Attr;
 import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
 import com.sun.tools.javac.comp.Env;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
@@ -68,6 +68,7 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
+import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.FIRSTASGOP;
 import static com.sun.tools.javac.code.TypeTag.CLASS;
 import static com.sun.tools.javac.code.TypeTag.FORALL;
 import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
@@ -388,14 +389,6 @@
              name != name.table.names._this;
     }
 
-    public boolean isFinal() {
-        return (flags() & FINAL) != 0;
-    }
-
-    public boolean isEffectivelyFinal() {
-        return (flags() & EFFECTIVELY_FINAL) != 0;
-    }
-
     public boolean isInterface() {
         return (flags() & INTERFACE) != 0;
     }
@@ -1564,9 +1557,7 @@
 
         @DefinedBy(Api.LANGUAGE_MODEL)
         public Object getConstantValue() { // Mirror API
-            return getConstKind() == ConstantKind.NORMAL ?
-                    Constants.decode(getConstValue(), type) :
-                    null;
+            return Constants.decode(getConstValue(), type);
         }
 
         public void setLazyConstValue(final Env<AttrContext> env,
@@ -1592,55 +1583,8 @@
             return data == ElementKind.RESOURCE_VARIABLE;
         }
 
-        /**
-         * Describes the constant associated with this variable (if any)
-         */
-        public enum ConstantKind {
-            /** no constant value */
-            NONE,
-            /** a compile-time constant (primitive or String) */
-            NORMAL,
-            /** a partial constant (Class, MethodHandle, MethodType, MethodHandles.Lookup) */
-            PARTIAL;
-        }
-
-        /**
-         * Returns the constant kind of this variable.
-         */
-        public ConstantKind getConstKind() {
-            Object val = getConstValue();
-            if (val == null) {
-                return ConstantKind.NONE;
-            } else if (val instanceof SpecialConstant) {
-                return ConstantKind.PARTIAL;
-            } else {
-                return ConstantKind.NORMAL;
-            }
-        }
-
-        /**
-         * Retrieves the constant value associated with this variable. This method expands partial
-         * constants in a context-sensitive way and should therefore be used during code generation
-         * to allow conditional folding (because effectively final variable might not have been
-         * detected yet in the frontend).
-         */
-        public final Object getConstValue(ClassSymbol userClass, Symtab syms) {
-            Object val = getConstValue();
-            switch (getConstKind()) {
-                case NORMAL:
-                    return val;
-                case PARTIAL:
-                    return ((SpecialConstant)val).getConstantValue(userClass);
-                default:
-                    return null;
-            }
-        }
-
-        /**
-         * Retrieves the constant value associated with this variable. If this variable has a
-         * partial constant value, it is returned as is.
-         */
         public Object getConstValue() {
+            // TODO: Consider if getConstValue and getConstantValue can be collapsed
             if (data == ElementKind.EXCEPTION_PARAMETER ||
                 data == ElementKind.RESOURCE_VARIABLE) {
                 return null;
@@ -1660,13 +1604,6 @@
 
         public void setData(Object data) {
             Assert.check(!(data instanceof Env<?>), this);
-            if (data instanceof SpecialConstant) {
-                SpecialConstant sc = (SpecialConstant)data;
-                if (sc.generateLDC()) {
-                    Object value = sc.getConstantValue(sc.getOwner());
-                    data = new SpecialConstant(value, sc.getOwner());
-                }
-            }
             this.data = data;
         }
 
@@ -2073,7 +2010,7 @@
     public static class DynamicMethodSymbol extends MethodSymbol {
 
         public Object[] staticArgs;
-        public MethodSymbol bsm;
+        public Symbol bsm;
         public int bsmKind;
 
         public DynamicMethodSymbol(Name name, Symbol owner, int bsmKind, MethodSymbol bsm, Type type, Object[] staticArgs) {
@@ -2089,31 +2026,6 @@
         }
     }
 
-    /** A class for condy.
-     */
-    public static class DynamicFieldSymbol extends Symbol {
-
-        public Object[] staticArgs;
-        public MethodSymbol bsm;
-        public int bsmKind;
-
-        public DynamicFieldSymbol(Name name, Symbol owner, int bsmKind, MethodSymbol bsm, Type type, Object[] staticArgs) {
-            super(Kind.VAR, 0, name, type, owner);
-            this.bsm = bsm;
-            this.bsmKind = bsmKind;
-            this.staticArgs = staticArgs;
-        }
-
-        public boolean isDynamic() {
-            return true;
-        }
-
-        @Override
-        public <R, P> R accept(ElementVisitor<R, P> v, P p) {
-            return v.visit(this, p);
-        }
-    }
-
     /** A class for predefined operators.
      */
     public static class OperatorSymbol extends MethodSymbol {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Sep 29 14:38:51 2017 -0700
@@ -169,12 +169,8 @@
     public final Type serializedLambdaType;
     public final Type varHandleType;
     public final Type methodHandleType;
-    public final Type methodHandlesLookupType;
-    public final Type constablesType;
-    public final Type dynamicConstantRefType;
-    public final Type intrinsicsType;
+    public final Type methodHandleLookupType;
     public final Type methodTypeType;
-    public final Type trackableConstantType;
     public final Type nativeHeaderType;
     public final Type throwableType;
     public final Type errorType;
@@ -497,12 +493,8 @@
         serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
         varHandleType = enterClass("java.lang.invoke.VarHandle");
         methodHandleType = enterClass("java.lang.invoke.MethodHandle");
-        methodHandlesLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
-        constablesType = enterClass("java.lang.invoke.Constables");
-        dynamicConstantRefType = enterClass("java.lang.invoke.DynamicConstantRef");
-        intrinsicsType = enterClass("java.lang.invoke.Intrinsics");
+        methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
         methodTypeType = enterClass("java.lang.invoke.MethodType");
-        trackableConstantType = enterClass("java.lang.annotation.TrackableConstant");
         errorType = enterClass("java.lang.Error");
         illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
         interruptedExceptionType = enterClass("java.lang.InterruptedException");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Fri Sep 29 14:38:51 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.TypeMetadata.Entry;
 import com.sun.tools.javac.code.Types.TypeMapping;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
 import com.sun.tools.javac.comp.Infer.IncorporationAction;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
@@ -172,32 +171,12 @@
      * The constant value of this type, null if this type does not
      * have a constant value attribute. Only primitive types and
      * strings (ClassType) can have a constant value attribute.
-     * If this variable has a partial constant value, it is returned as is.
      * @return the constant value attribute of this type
      */
     public Object constValue() {
         return null;
     }
 
-    public boolean hasIntrinsicConstValue() {
-        return false;
-    }
-
-    /**
-     * Retrieves the constant value associated with this type. This method expands partial
-     * constants in a context-sensitive way and should therefore be used during code generation
-     * to allow conditional folding (because effectively final variable might not have been
-     * detected yet in the frontend).
-     */
-    public final Object constValue(ClassSymbol userClass, Symtab syms) {
-        Object val = constValue();
-        if (val instanceof SpecialConstant) {
-            SpecialConstant sc = (SpecialConstant)val;
-            val = sc.getConstantValue(userClass);
-        }
-        return val;
-    }
-
     /** Is this a constant type whose value is false?
      */
     public boolean isFalse() {
@@ -334,8 +313,8 @@
     /** Define a constant type, of the same kind as this type
      *  and with given constant value
      */
-    public Type constType(final Object constValue) {
-        throw new AssertionError("trying to create a constant for type " + this);
+    public Type constType(Object constValue) {
+        throw new AssertionError();
     }
 
     /**
@@ -750,17 +729,12 @@
          *  and with given constant value
          */
         @Override
-        public Type constType(final Object constValue) {
+        public Type constType(Object constValue) {
+            final Object value = constValue;
             return new JCPrimitiveType(tag, tsym, metadata) {
                     @Override
                     public Object constValue() {
-                        return constValue;
-                    }
-                    @Override
-                    public boolean hasIntrinsicConstValue() {
-                        return (constValue instanceof SpecialConstant) ?
-                            ((SpecialConstant)constValue).hasIntrisicValue() :
-                            true;
+                        return value;
                     }
                     @Override
                     public Type baseType() {
@@ -792,7 +766,7 @@
         public boolean isFalse() {
             return
                 tag == BOOLEAN &&
-                hasIntrinsicConstValue() &&
+                constValue() != null &&
                 ((Integer)constValue()).intValue() == 0;
         }
 
@@ -802,7 +776,7 @@
         public boolean isTrue() {
             return
                 tag == BOOLEAN &&
-                hasIntrinsicConstValue() &&
+                constValue() != null &&
                 ((Integer)constValue()).intValue() != 0;
         }
 
@@ -1018,22 +992,16 @@
             return v.visitClassType(this, s);
         }
 
-        @Override
-        public Type constType(final Object constValue) {
+        public Type constType(Object constValue) {
+            final Object value = constValue;
             return new ClassType(getEnclosingType(), typarams_field, tsym, metadata) {
                     @Override
                     public Object constValue() {
-                        return constValue;
-                    }
-                    @Override
-                    public boolean hasIntrinsicConstValue() {
-                        return (constValue instanceof SpecialConstant) ?
-                                ((SpecialConstant)constValue).hasIntrisicValue() :
-                                true;
+                        return value;
                     }
                     @Override
                     public Type baseType() {
-                        return ClassType.this;
+                        return tsym.type;
                     }
                 };
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java	Fri Sep 29 14:38:51 2017 -0700
@@ -42,36 +42,36 @@
 public enum TypeTag {
     /** The tag of the basic type `byte'.
      */
-    BYTE(BYTE_CLASS, BYTE_SUPERCLASSES, true, byte.class),
+    BYTE(BYTE_CLASS, BYTE_SUPERCLASSES, true),
 
     /** The tag of the basic type `char'.
      */
-    CHAR(CHAR_CLASS, CHAR_SUPERCLASSES, true, char.class),
+    CHAR(CHAR_CLASS, CHAR_SUPERCLASSES, true),
 
     /** The tag of the basic type `short'.
      */
-    SHORT(SHORT_CLASS, SHORT_SUPERCLASSES, true, short.class),
+    SHORT(SHORT_CLASS, SHORT_SUPERCLASSES, true),
 
     /** The tag of the basic type `long'.
      */
-    LONG(LONG_CLASS, LONG_SUPERCLASSES, true, long.class),
+    LONG(LONG_CLASS, LONG_SUPERCLASSES, true),
 
     /** The tag of the basic type `float'.
      */
-    FLOAT(FLOAT_CLASS, FLOAT_SUPERCLASSES, true, float.class),
+    FLOAT(FLOAT_CLASS, FLOAT_SUPERCLASSES, true),
     /** The tag of the basic type `int'.
      */
-    INT(INT_CLASS, INT_SUPERCLASSES, true, int.class),
+    INT(INT_CLASS, INT_SUPERCLASSES, true),
     /** The tag of the basic type `double'.
      */
-    DOUBLE(DOUBLE_CLASS, DOUBLE_CLASS, true, double.class),
+    DOUBLE(DOUBLE_CLASS, DOUBLE_CLASS, true),
     /** The tag of the basic type `boolean'.
      */
-    BOOLEAN(0, 0, true, boolean.class),
+    BOOLEAN(0, 0, true),
 
     /** The tag of the type `void'.
      */
-    VOID(0, 0, false, void.class),
+    VOID,
 
     /** The tag of all class and interface types.
      */
@@ -138,17 +138,15 @@
     final int superClasses;
     final int numericClass;
     final boolean isPrimitive;
-    public final Class<?> theClass;
 
     private TypeTag() {
-        this(0, 0, false, null);
+        this(0, 0, false);
     }
 
-    private TypeTag(int numericClass, int superClasses, boolean isPrimitive, Class<?> theClass) {
+    private TypeTag(int numericClass, int superClasses, boolean isPrimitive) {
         this.superClasses = superClasses;
         this.numericClass = numericClass;
         this.isPrimitive = isPrimitive;
-        this.theClass = theClass;
     }
 
     public static class NumericClasses {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Fri Sep 29 14:38:51 2017 -0700
@@ -58,7 +58,6 @@
 import static com.sun.tools.javac.code.Type.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.jvm.ClassFile.externalize;
-
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 
 /**
@@ -100,8 +99,6 @@
     private final FunctionDescriptorLookupError functionDescriptorLookupError;
 
     public final Warner noWarnings;
-    private final boolean doConstantFold;
-    private final SpecialConstantUtils specialConstUtils;
 
     // <editor-fold defaultstate="collapsed" desc="Instantiating">
     public static Types instance(Context context) {
@@ -126,9 +123,6 @@
         diags = JCDiagnostic.Factory.instance(context);
         functionDescriptorLookupError = new FunctionDescriptorLookupError();
         noWarnings = new Warner(null);
-        Options options = Options.instance(context);
-        doConstantFold = options.isSet("doConstantFold");
-        specialConstUtils = new SpecialConstantUtils(context);
     }
     // </editor-fold>
 
@@ -1261,9 +1255,6 @@
      *   (v) is native.
     */
    public boolean isSignaturePolymorphic(MethodSymbol msym) {
-       if (doConstantFold && specialConstUtils.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) &&
@@ -2307,7 +2298,7 @@
     public boolean isAssignable(Type t, Type s, Warner warn) {
         if (t.hasTag(ERROR))
             return true;
-        if (t.getTag().isSubRangeOf(INT) && t.hasIntrinsicConstValue()) {
+        if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
             int value = ((Number)t.constValue()).intValue();
             switch (s.getTag()) {
             case BYTE:
@@ -4282,22 +4273,6 @@
         return syms.enterClass(syms.java_base, syms.boxedName[t.getTag().ordinal()]);
     }
 
-    public ClassSymbol boxedClass(String descriptor) {
-        switch (descriptor) {
-            case "I": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.INT.ordinal()]);
-            case "J": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.LONG.ordinal()]);
-            case "S": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.SHORT.ordinal()]);
-            case "B": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.BYTE.ordinal()]);
-            case "C": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.CHAR.ordinal()]);
-            case "F": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.FLOAT.ordinal()]);
-            case "D": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.DOUBLE.ordinal()]);
-            case "Z": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.BOOLEAN.ordinal()]);
-            case "V": return syms.enterClass(syms.java_base, syms.boxedName[TypeTag.VOID.ordinal()]);
-            default:
-                throw new AssertionError("invalid primitive descriptor " + descriptor);
-        }
-    }
-
     /**
      * Return the boxed type if 't' is primitive, otherwise return 't' itself.
      */
@@ -4438,16 +4413,11 @@
         if (!currentA.isEmpty() || !currentT.isEmpty() || !currentS.isEmpty())
             return erasure(t); // some "rare" type involved
 
-        if (captured) {
-            Type result = new ClassType(cls.getEnclosingType(), S, cls.tsym, cls.getMetadata());
-            Object cvalue = cls.constValue();
-            if (doConstantFold && cvalue != null) {
-                result = result.constType(cvalue);
-            }
-            return result;
-        } else {
+        if (captured)
+            return new ClassType(cls.getEnclosingType(), S, cls.tsym,
+                                 cls.getMetadata());
+        else
             return t;
-        }
     }
     // where
         public List<Type> freshTypeVariables(List<Type> types) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Sep 29 14:38:51 2017 -0700
@@ -39,20 +39,16 @@
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.code.Scope.WriteableScope;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.Symbol.VarSymbol.ConstantKind;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.TypeMetadata.Annotations;
 import com.sun.tools.javac.code.Types.FunctionDescriptorLookupError;
 import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext;
 import com.sun.tools.javac.comp.Check.CheckContext;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
 import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
 import com.sun.tools.javac.jvm.*;
-
 import static com.sun.tools.javac.resources.CompilerProperties.Fragments.Diamond;
 import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArg;
 import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArgs;
-
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
@@ -73,7 +69,6 @@
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.code.TypeTag.WILDCARD;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 
 /** This is the main context-dependent analysis phase in GJC. It
@@ -153,6 +148,7 @@
         argumentAttr = ArgumentAttr.instance(context);
 
         Options options = Options.instance(context);
+
         Source source = Source.instance(context);
         allowStringsInSwitch = source.allowStringsInSwitch();
         allowPoly = source.allowPoly();
@@ -162,7 +158,7 @@
         allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
         sourceName = source.name;
         useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
-        doConstantFold = options.isSet("doConstantFold");
+
         statInfo = new ResultInfo(KindSelector.NIL, Type.noType);
         varAssignmentInfo = new ResultInfo(KindSelector.ASG, Type.noType);
         unknownExprInfo = new ResultInfo(KindSelector.VAL, Type.noType);
@@ -199,11 +195,6 @@
     boolean useBeforeDeclarationWarning;
 
     /**
-     * Switch: fold special constants
-     */
-    final boolean doConstantFold;
-
-    /**
      * Switch: allow strings in switch?
      */
     boolean allowStringsInSwitch;
@@ -2030,7 +2021,6 @@
             Type capturedRes = resultInfo.checkContext.inferenceContext().cachedCapture(tree, restype, true);
             result = check(tree, capturedRes, KindSelector.VAL, resultInfo);
         }
-        tree.resolutionPhase = localEnv.info.pendingResolutionPhase;
         chk.validate(tree.typeargs, localEnv);
     }
     //where
@@ -3949,19 +3939,8 @@
 
                 // If the variable is a constant, record constant value in
                 // computed type.
-                if (!doConstantFold) {
-                    if (v.getConstValue() != null && isStaticReference(tree)) {
-                        owntype = owntype.constType(v.getConstValue());
-                    }
-                } else {
-                    if (v.name == names._class) {
-                        owntype = owntype.constType(new SpecialConstant(site.hasTag(ARRAY) ? site : site.tsym, env));
-                    } else if (isStaticReference(tree) && v.getConstKind() != ConstantKind.NONE) {
-                        // If the variable is a constant, record constant value in
-                        // computed type.
-                        owntype = owntype.constType(v.getConstValue());
-                    }
-                }
+                if (v.getConstValue() != null && isStaticReference(tree))
+                    owntype = owntype.constType(v.getConstValue());
 
                 if (resultInfo.pkind == KindSelector.VAL) {
                     owntype = capture(owntype); // capture "names as expressions"
@@ -4116,7 +4095,7 @@
         private boolean isStaticEnumField(VarSymbol v) {
             return Flags.isEnum(v.owner) &&
                    Flags.isStatic(v) &&
-                   v.getConstValue() == null &&
+                   !Flags.isConstant(v) &&
                    v.name != names._class;
         }
 
@@ -5086,7 +5065,7 @@
      * the compiler has encountered some errors (which might have ended up
      * terminating attribution abruptly); if the compiler is used in fail-over
      * mode (e.g. by an IDE) and the AST contains semantic errors, this routine
-     * prevents NPE to be propagated during subsequent compilation steps.
+     * prevents NPE to be progagated during subsequent compilation steps.
      */
     public void postAttr(JCTree tree) {
         new PostAttrAnalyzer().scan(tree);
@@ -5255,4 +5234,5 @@
             }
         }.scan(pid);
     }
+
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Sep 29 14:38:51 2017 -0700
@@ -3445,7 +3445,7 @@
      *  @param operand       The right hand operand for the expression
      */
     void checkDivZero(final DiagnosticPosition pos, Symbol operator, Type operand) {
-        if (operand.hasIntrinsicConstValue()
+        if (operand.constValue() != null
             && operand.getTag().isSubRangeOf(LONG)
             && ((Number) (operand.constValue())).longValue() == 0) {
             int opc = ((OperatorSymbol)operator).opcode;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java	Fri Sep 29 14:38:51 2017 -0700
@@ -25,9 +25,7 @@
 
 package com.sun.tools.javac.comp;
 
-
 import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.util.*;
 
@@ -43,10 +41,10 @@
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
-strictfp public class ConstFold {
+strictfp class ConstFold {
     protected static final Context.Key<ConstFold> constFoldKey = new Context.Key<>();
 
-    private final Symtab syms;
+    private Symtab syms;
 
     public static ConstFold instance(Context context) {
         ConstFold instance = context.get(constFoldKey);
@@ -57,6 +55,7 @@
 
     private ConstFold(Context context) {
         context.put(constFoldKey, this);
+
         syms = Symtab.instance(context);
     }
 
@@ -311,29 +310,29 @@
      *                    ttype.
      *  @param ttype      The target type of the coercion.
      */
-    Type coerce(Type etype, Type ttype) {
-        // WAS if (etype.baseType() == ttype.baseType())
-        if (etype.tsym.type == ttype.tsym.type)
-            return etype;
-        if (etype.isNumeric()) {
-            Object n = etype.constValue();
-            switch (ttype.getTag()) {
-            case BYTE:
-                return syms.byteType.constType(0 + (byte)intValue(n));
-            case CHAR:
-                return syms.charType.constType(0 + (char)intValue(n));
-            case SHORT:
-                return syms.shortType.constType(0 + (short)intValue(n));
-            case INT:
-                return syms.intType.constType(intValue(n));
-            case LONG:
-                return syms.longType.constType(longValue(n));
-            case FLOAT:
-                return syms.floatType.constType(floatValue(n));
-            case DOUBLE:
-                return syms.doubleType.constType(doubleValue(n));
-            }
-        }
-        return ttype;
-    }
+     Type coerce(Type etype, Type ttype) {
+         // WAS if (etype.baseType() == ttype.baseType())
+         if (etype.tsym.type == ttype.tsym.type)
+             return etype;
+         if (etype.isNumeric()) {
+             Object n = etype.constValue();
+             switch (ttype.getTag()) {
+             case BYTE:
+                 return syms.byteType.constType(0 + (byte)intValue(n));
+             case CHAR:
+                 return syms.charType.constType(0 + (char)intValue(n));
+             case SHORT:
+                 return syms.shortType.constType(0 + (short)intValue(n));
+             case INT:
+                 return syms.intType.constType(intValue(n));
+             case LONG:
+                 return syms.longType.constType(longValue(n));
+             case FLOAT:
+                 return syms.floatType.constType(floatValue(n));
+             case DOUBLE:
+                 return syms.doubleType.constType(doubleValue(n));
+             }
+         }
+         return ttype;
+     }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstablesVisitor.java	Thu Sep 28 22:16:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,593 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.comp;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.Type.ArrayType;
-import com.sun.tools.javac.code.Type.JCNoType;
-import com.sun.tools.javac.code.Type.MethodType;
-import com.sun.tools.javac.code.Types;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
-import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase;
-import com.sun.tools.javac.jvm.Pool;
-import com.sun.tools.javac.resources.CompilerProperties.Errors;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCBinary;
-import com.sun.tools.javac.tree.JCTree.JCConditional;
-import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
-import com.sun.tools.javac.tree.JCTree.JCIdent;
-import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
-import com.sun.tools.javac.tree.JCTree.JCTypeCast;
-import com.sun.tools.javac.tree.JCTree.JCUnary;
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.tree.TreeInfo;
-import com.sun.tools.javac.tree.TreeScanner;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Names;
-import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.util.SpecialConstantUtils;
-
-import static com.sun.tools.javac.code.Flags.EFFECTIVELY_FINAL;
-import static com.sun.tools.javac.code.Flags.FINAL;
-import static com.sun.tools.javac.code.Kinds.Kind.VAR;
-import static com.sun.tools.javac.code.TypeTag.ARRAY;
-import static com.sun.tools.javac.code.TypeTag.NONE;
-import static com.sun.tools.javac.tree.JCTree.Tag.SELECT;
-
-/**
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- */
-public class ConstablesVisitor extends TreeScanner {
-    protected static final Context.Key<ConstablesVisitor> constablesVisitorKey = new Context.Key<>();
-
-    public static ConstablesVisitor instance(Context context) {
-        ConstablesVisitor instance = context.get(constablesVisitorKey);
-        if (instance == null)
-            instance = new ConstablesVisitor(context);
-        return instance;
-    }
-
-    private final Symtab syms;
-    private final Names names;
-    private final Types types;
-    private final Resolve rs;
-    private final Log log;
-    private final ConstFold cfolder;
-    private final SpecialConstantUtils specialConstantUtils;
-
-    protected ConstablesVisitor(Context context) {
-        context.put(constablesVisitorKey, this);
-        Options options = Options.instance(context);
-        doConstantFold = options.isSet("doConstantFold");
-        syms = Symtab.instance(context);
-        names = Names.instance(context);
-        types = Types.instance(context);
-        rs = Resolve.instance(context);
-        log = Log.instance(context);
-        cfolder = ConstFold.instance(context);
-        specialConstantUtils = new SpecialConstantUtils(context);
-        specialConstantsAnalyzer = new SpecialConstantsHelper(types, names, syms, rs, log, specialConstantUtils);
-    }
-
-    /**
-     * Switch: fold special constants
-     */
-    private final boolean doConstantFold;
-
-    private Env<AttrContext> attrEnv;
-
-    public void analyzeTree(JCTree tree, Env<AttrContext> attrEnv) {
-        if (!doConstantFold) {
-            return;
-        }
-        this.attrEnv = attrEnv;
-        scan(tree);
-    }
-
-    @Override
-    public void visitVarDef(JCVariableDecl tree) {
-        super.visitVarDef(tree);
-        if (tree.init != null) {
-            VarSymbol v = tree.sym;
-            Object val = tree.init.type.constValue();
-            if (val != null &&
-                    ((v.flags_field & FINAL) != 0 ||
-                    (v.flags_field & EFFECTIVELY_FINAL) != 0)) {
-                v.setData(val);
-                tree.type = tree.type.constType(val);
-            }
-        }
-    }
-
-    @Override
-    public void visitBinary(JCBinary tree) {
-        super.visitBinary(tree);
-        Type left = tree.lhs.type;
-        Type right = tree.rhs.type;
-        if (tree.type.constValue() == null &&
-                left.hasIntrinsicConstValue() &&
-                right.hasIntrinsicConstValue()) {
-            Type ctype = cfolder.fold2(tree.operator.opcode, left, right);
-            if (ctype != null) {
-                tree.type = cfolder.coerce(ctype, tree.type);
-            }
-        }
-    }
-
-    @Override
-    public void visitUnary(JCUnary tree) {
-        super.visitUnary(tree);
-        if (tree.type.constValue() == null && tree.arg.type.hasIntrinsicConstValue()) {
-            Type ctype = cfolder.fold1(tree.operator.opcode, tree.type);
-            if (ctype != null) {
-                tree.type = cfolder.coerce(ctype, tree.type);
-            }
-        }
-    }
-
-    @Override
-    public void visitConditional(JCConditional tree) {
-        super.visitConditional(tree);
-        if (tree.type.constValue() == null &&
-            tree.cond.type.constValue() != null &&
-            tree.truepart.type.constValue() != null &&
-            tree.falsepart.type.constValue() != null &&
-            !tree.type.hasTag(NONE)) {
-            //constant folding
-            tree.type = cfolder.coerce(tree.cond.type.isTrue() ? tree.truepart.type : tree.falsepart.type, tree.type);
-        }
-    }
-
-    @Override
-    public void visitTypeCast(JCTypeCast tree) {
-        super.visitTypeCast(tree);
-        if (tree.type.constValue() == null &&
-                tree.expr.type.constValue() != null) {
-            tree.type = coerce(tree.expr.type, tree.type);
-        }
-    }
-
-    Type coerce(Type etype, Type ttype) {
-        Type coercedType = cfolder.coerce(etype, ttype);
-        if (coercedType.constValue() == null) {
-            // constant value lost in the intent
-            if (types.isConvertible(etype, ttype)) {
-                Type unboxedType = types.unboxedType(ttype);
-                if (unboxedType != Type.noType) {
-                    coercedType = cfolder.coerce(etype, unboxedType);
-                    return ttype.constType(coercedType.constValue());
-                }
-            }
-        }
-        return coercedType;
-    }
-
-    @Override
-    public void visitIdent(JCIdent tree) {
-        super.visitIdent(tree);
-        Symbol sym = TreeInfo.symbol(tree);
-        if (sym.kind == VAR) {
-            VarSymbol v = (VarSymbol)sym;
-            if (v.getConstValue() != null) {
-                tree.type = tree.type.constType(v.getConstValue());
-            } else {
-                Type constantType = specialConstantsAnalyzer.foldTrackableField(tree, attrEnv);
-                if (constantType != null) {
-                    tree.type = constantType;
-                }
-            }
-        }
-    }
-
-    @Override
-    public void visitSelect(JCFieldAccess tree) {
-        super.visitSelect(tree);
-        Type constantType = specialConstantsAnalyzer.foldTrackableField(tree, attrEnv);
-        if (constantType != null) {
-            tree.type = constantType;
-        }
-    }
-
-    @Override
-    public void visitApply(JCMethodInvocation tree) {
-        super.visitApply(tree);
-        Name methName = TreeInfo.name(tree.meth);
-        boolean isConstructorCall = methName == names._this || methName == names._super;
-        if (!isConstructorCall) {
-            Type constantType = specialConstantsAnalyzer.foldMethodInvocation(tree, attrEnv);
-            if (constantType != null) {
-                if (specialConstantUtils.isIntrinsicsLDCInvocation(TreeInfo.symbol(tree.meth)) &&
-                    tree.args.head.type.tsym == syms.dynamicConstantRefType.tsym) {
-                    Object condy = ((SpecialConstant)constantType.constValue()).getConstantValue(attrEnv.enclClass.sym);
-                    Object classRef = specialConstantUtils.invokeReflectiveMethod(specialConstantUtils.dynamicConstantClass, condy, "type");
-                    String descriptor = (String)specialConstantUtils.invokeReflectiveMethod(specialConstantUtils.classRefClass, classRef, "descriptorString");
-                    Type newType = specialConstantUtils.descriptorToType(descriptor, attrEnv.enclClass.sym.packge().modle, false);
-
-                    Object newInternalConstant = specialConstantUtils.convertConstant(tree, attrEnv,
-                            condy, attrEnv.enclClass.sym.packge().modle);
-                    ((Pool.ConstantDynamic)newInternalConstant).updateType(newType);
-                    SpecialConstant constant = (SpecialConstant)constantType.constValue();
-                    constant = constant.dup();
-                    constant.update(condy, newInternalConstant);
-
-                    tree.type = newType.constType(constant);
-                    MethodType oldMT = tree.meth.type.asMethodType();
-                    MethodType newMT = new MethodType(oldMT.argtypes, newType, oldMT.thrown, syms.methodClass);
-                    tree.meth.type = newMT;
-                } else {
-                    tree.type = constantType;
-                }
-            }
-        }
-    }
-
-    final SpecialConstantsHelper specialConstantsAnalyzer;
-
-    public static class SpecialConstantsHelper {
-        final Types types;
-        final Names names;
-        final Symtab syms;
-        final Resolve rs;
-        final Log log;
-        final SpecialConstantUtils specialConstantUtils;
-
-        public SpecialConstantsHelper(
-                Types types,
-                Names names,
-                Symtab syms,
-                Resolve rs,
-                Log log,
-                SpecialConstantUtils specialConstantUtils) {
-            this.syms = syms;
-            this.types = types;
-            this.names = names;
-            this.rs = rs;
-            this.log = log;
-            this.specialConstantUtils = specialConstantUtils;
-        }
-
-        /* This method doesnt verify that the annotated field is static it is assumed that
-         * it has to be
-         */
-        Type foldTrackableField(final JCTree tree, final Env<AttrContext> env) {
-            Symbol sym = TreeInfo.symbol(tree);
-            boolean trackableConstant = sym.attribute(syms.trackableConstantType.tsym) != null &&
-                    sym.packge().modle == syms.java_base;
-            if (trackableConstant) {
-                String className = sym.owner.type.tsym.flatName().toString();
-                try {
-                    Class<?> constablesClass = Class.forName(className, false, null);
-                    MemberKind mKind = getMemberKind(constablesClass, sym.name.toString());
-                    if (mKind == MemberKind.METHOD) {
-                        // we are in the middle of a method invocation bail out
-                        return null;
-                    }
-                    Field theField = constablesClass.getField(sym.name.toString());
-                    Object value = theField.get(null);
-                    if (value != null) {
-                        return tree.type.constType(new SpecialConstant(value, env));
-                    }
-                } catch (ClassNotFoundException |
-                        NoSuchFieldException |
-                        IllegalAccessException ex) {
-                    log.error(tree, Errors.ReflectiveError(sym.name.toString(), className));
-                }
-            }
-            return null;
-        }
-
-        enum MemberKind {
-            FIELD,
-            METHOD
-        }
-
-        MemberKind getMemberKind(Class<?> aClass, String name) {
-            try {
-                aClass.getField(name);
-                return MemberKind.FIELD;
-            } catch (NoSuchFieldException ex) {
-                return MemberKind.METHOD;
-            }
-        }
-
-        Type foldMethodInvocation(final JCMethodInvocation tree, final Env<AttrContext> env) {
-            Symbol msym = TreeInfo.symbol(tree.meth);
-            Object constant = null;
-            boolean generateLDC = false;
-            boolean trackableConstant = msym.attribute(syms.trackableConstantType.tsym) != null &&
-                    msym.packge().modle == syms.java_base;
-            boolean isLDC = msym.owner.type.tsym == syms.intrinsicsType.tsym && msym.name == names.ldc;
-            if (trackableConstant || isLDC) {
-                List<Type> constantArgumentTypes = tree.args.stream()
-                        .map(e -> e.type)
-                        .collect(List.collector());
-                List<Object> constantArgumentValues = constantArgumentTypes.stream()
-                        .map(t -> getConstantArgumentType(env, t))
-                        .collect(List.collector());
-                boolean allConstants = constantArgumentValues.stream().allMatch(t -> t != SENTINEL);
-                if (allConstants) {
-                    if (trackableConstant) {
-                        Type qualifier = (tree.meth.hasTag(SELECT))
-                            ? ((JCFieldAccess) tree.meth).selected.type
-                            : env.enclClass.sym.type;
-                        constant = invokeConstablesMethod(tree, qualifier, env, constantArgumentValues);
-                    } else if (isLDC) {
-                        constant = constantArgumentTypes.head.constValue();
-                        generateLDC = true;
-                    }
-                }
-                if (constant != null) {
-                    if (generateLDC) {
-                        return tree.type.constType(new FoldableConstant(constant));
-                    } else {
-                        return tree.type.constType(new SpecialConstant(constant, env));
-                    }
-                }
-            }
-            return null;
-        }
-
-        // where
-            Object invokeConstablesMethod(
-                    final JCMethodInvocation tree,
-                    Type qualifier,
-                    final Env<AttrContext> env,
-                    List<Object> constantArgumentValues) {
-                String className = "";
-                Name methodName = names.empty;
-                try {
-                    Symbol msym = TreeInfo.symbol(tree.meth);
-                    Object instance = qualifier.constValue();
-                    if (instance instanceof SpecialConstant) {
-                        instance = ((SpecialConstant)instance).getConstantValue(env.enclClass.sym);
-                    }
-                    className = msym.owner.type.tsym.flatName().toString();
-                    methodName = msym.name;
-                    Class<?> constablesClass = Class.forName(className, false, null);
-                    MethodType mt = msym.type.asMethodType();
-                    java.util.List<Class<?>> argumentTypes =
-                            mt.argtypes.stream().map(t -> getClassForType(t)).collect(List.collector());
-                    Method theMethod = constablesClass.getDeclaredMethod(methodName.toString(),
-                            argumentTypes.toArray(new Class<?>[argumentTypes.size()]));
-                    int modifiers = theMethod.getModifiers();
-                    Type varTypeElement = mt.getParameterTypes().last();
-                    if (varTypeElement != null) {
-                        varTypeElement = types.elemtype(varTypeElement);
-                    }
-                    Object[] args = boxArgs(
-                            mt.argtypes,
-                            constantArgumentValues,
-                            tree.resolutionPhase == MethodResolutionPhase.VARARITY ? varTypeElement : null);
-                    if ((modifiers & Modifier.STATIC) == 0) {
-                        return (instance != null) ? theMethod.invoke(instance, args) : null;
-                    }
-                    return theMethod.invoke(null, args);
-                } catch (ClassNotFoundException |
-                        SecurityException |
-                        NoSuchMethodException |
-                        IllegalAccessException |
-                        IllegalArgumentException |
-                        InvocationTargetException ex) {
-                    log.error(tree, Errors.ReflectiveError(methodName.toString(), className));
-                    return null;
-                }
-            }
-
-            Class<?> getClassForType(Type t) {
-                try {
-                    if (t.isPrimitiveOrVoid()) {
-                        return t.getTag().theClass;
-                    } else {
-                        return Class.forName(getFlatName(t), false, null);
-                    }
-                } catch (ClassNotFoundException ex) {
-                    return null;
-                }
-            }
-
-            String getFlatName(Type t) {
-                String flatName = t.tsym.flatName().toString();
-                if (t.hasTag(ARRAY)) {
-                    flatName = "";
-                    while (t.hasTag(ARRAY)) {
-                        ArrayType at = (ArrayType)t;
-                        flatName += "[";
-                        t = at.elemtype;
-                    }
-                    flatName += "L" + t.tsym.flatName().toString() + ';';
-                }
-                return flatName;
-            }
-
-            Object[] boxArgs(List<Type> parameters, List<Object> _args, Type varargsElement) {
-                java.util.List<Object> result = new java.util.ArrayList<>();
-                List<Object> args = _args;
-                if (parameters.isEmpty()) return new Object[0];
-                while (parameters.tail.nonEmpty()) {
-                    result.add(args.head);
-                    args = args.tail;
-                    parameters = parameters.tail;
-                }
-                if (varargsElement != null) {
-                    java.util.List<Object> elems = new java.util.ArrayList<>();
-                    while (args.nonEmpty()) {
-                        elems.add(args.head);
-                        args = args.tail;
-                    }
-                    Class<?> arrayClass = null;
-                    try {
-                        arrayClass = Class.forName(getFlatName(varargsElement), false, null);
-                    } catch (ClassNotFoundException ex) {}
-                    Object arr = Array.newInstance(arrayClass, elems.size());
-                    for (int i = 0; i < elems.size(); i++) {
-                        Array.set(arr, i, elems.get(i));
-                    }
-                    result.add(arr);
-                } else {
-                    if (args.length() != 1) throw new AssertionError(args);
-                    result.add(args.head);
-                }
-                return result.toArray();
-            }
-
-            private static final Object SENTINEL = new Object(); //ListBuffer.add doesn't like nulls
-
-            private static final JCNoType stringConstantMarker = new JCNoType() {
-                @Override @DefinedBy(Api.LANGUAGE_MODEL)
-                public String toString() {
-                    return "string constant";
-                }
-            };
-
-            private Object getConstantArgumentType(Env<AttrContext> env, Type type) {
-                Object val = type.constValue();
-                if (val instanceof SpecialConstant) {
-                    val = ((SpecialConstant)val).getConstantValue(env.enclClass.sym);
-                }
-                return val == null ? SENTINEL : val;
-            }
-
-        public static class SpecialConstant {
-            protected Object value;
-            private Symbol owner;
-
-            SpecialConstant() {}
-
-            public SpecialConstant(Object value, Env<AttrContext> env) {
-                this(value, env.enclClass.sym.outermostClass());
-            }
-
-            public SpecialConstant(Object value, Symbol owner) {
-                this.value = value;
-                this.owner = owner;
-            }
-
-            public SpecialConstant dup() {
-                SpecialConstant dup = new SpecialConstant();
-                dup.owner = owner;
-                dup.value = value;
-                return dup;
-            }
-
-            public Symbol getOwner() {
-                return owner;
-            }
-
-            public Object getConstantValue(Symbol userClass) {
-                return (userClass.outermostClass() != owner) ? null : value;
-            }
-
-            public boolean generateLDC() {
-                return false;
-            }
-
-            @Override
-            public String toString() {
-                return (value != null) ? value.toString() : null;
-            }
-
-            public boolean hasIntrisicValue() {
-                if (value instanceof SpecialConstant) {
-                    return ((SpecialConstant)value).hasIntrisicValue();
-                } else {
-                    return value instanceof Number ||
-                           value instanceof String ||
-                           value instanceof Boolean ||
-                           value instanceof Character;
-                }
-            }
-
-            void update(Object oldValue, Object newValue) {
-                if (value == oldValue) {
-                    value = newValue;
-                }
-            }
-        }
-
-        public static class FoldableConstant extends SpecialConstant {
-
-            FoldableConstant(Object value) {
-                this.value = value;
-            }
-
-            @Override
-            public Object getConstantValue(Symbol userClass) {
-                return value instanceof SpecialConstant ?
-                        ((SpecialConstant)value).getConstantValue(userClass) : value;
-            }
-
-            @Override
-            public boolean generateLDC() {
-                return true;
-            }
-
-            @Override
-            public Symbol getOwner() {
-                return value instanceof SpecialConstant ?
-                        ((SpecialConstant)value).getOwner() : null;
-            }
-
-            @Override
-            public boolean hasIntrisicValue() {
-                return value instanceof SpecialConstant ?
-                        ((SpecialConstant)value).hasIntrisicValue() : true;
-            }
-
-            @Override
-            public FoldableConstant dup() {
-                return new FoldableConstant(
-                        value instanceof SpecialConstant ?
-                                ((SpecialConstant)value).dup() :
-                                value);
-            }
-
-            void update(Object oldValue, Object newValue) {
-                if (value instanceof SpecialConstant) {
-                    ((SpecialConstant)value).update(oldValue, newValue);
-                } else {
-                    value = newValue;
-                }
-            }
-        }
-    }
-}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Sep 29 14:38:51 2017 -0700
@@ -564,7 +564,32 @@
         final Type restype;
 
         if (spMethod == null || types.isSameType(spMethod.getReturnType(), syms.objectType, true)) {
-            restype = getSigPolyReturnType(env);
+            // The return type of the polymorphic signature is polymorphic,
+            // and is computed from the enclosing tree E, as follows:
+            // if E is a cast, then use the target type of the cast expression
+            // as a return type; if E is an expression statement, the return
+            // type is 'void'; otherwise
+            // the return type is simply 'Object'. A correctness check ensures
+            // that env.next refers to the lexically enclosing environment in
+            // which the polymorphic signature call environment is nested.
+
+            switch (env.next.tree.getTag()) {
+                case TYPECAST:
+                    JCTypeCast castTree = (JCTypeCast)env.next.tree;
+                    restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ?
+                              castTree.clazz.type :
+                              syms.objectType;
+                    break;
+                case EXEC:
+                    JCTree.JCExpressionStatement execTree =
+                            (JCTree.JCExpressionStatement)env.next.tree;
+                    restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ?
+                              syms.voidType :
+                              syms.objectType;
+                    break;
+                default:
+                    restype = syms.objectType;
+            }
         } else {
             // The return type of the polymorphic signature is fixed
             // (not polymorphic)
@@ -582,32 +607,6 @@
                                           syms.methodClass);
         return mtype;
     }
-
-    public Type getSigPolyReturnType(Env<AttrContext> env) {
-        // The return type of the polymorphic signature is polymorphic,
-        // and is computed from the enclosing tree E, as follows:
-        // if E is a cast, then use the target type of the cast expression
-        // as a return type; if E is an expression statement, the return
-        // type is 'void'; otherwise
-        // the return type is simply 'Object'. A correctness check ensures
-        // that env.next refers to the lexically enclosing environment in
-        // which the polymorphic signature call environment is nested.
-        switch (env.next.tree.getTag()) {
-            case TYPECAST:
-                JCTypeCast castTree = (JCTypeCast)env.next.tree;
-                return (TreeInfo.skipParens(castTree.expr) == env.tree) ?
-                          castTree.clazz.type :
-                          syms.objectType;
-            case EXEC:
-                JCTree.JCExpressionStatement execTree =
-                        (JCTree.JCExpressionStatement)env.next.tree;
-                return (TreeInfo.skipParens(execTree.expr) == env.tree) ?
-                          syms.voidType :
-                          syms.objectType;
-            default:
-                return syms.objectType;
-        }
-    }
     //where
         class ImplicitArgType extends DeferredAttr.DeferredTypeMap {
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Sep 29 14:38:51 2017 -0700
@@ -69,8 +69,7 @@
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.type.TypeKind;
 
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.code.Symbol.DynamicFieldSymbol;
+import com.sun.tools.javac.main.Option;
 
 /**
  * This pass desugars lambda expressions into static methods
@@ -149,10 +148,6 @@
         dumpLambdaToMethodStats = options.isSet("debug.dumpLambdaToMethodStats");
         attr = Attr.instance(context);
         forceSerializable = options.isSet("forceSerializable");
-        doConstantFold = options.isSet("doConstantFold");
-        condyForLambda = options.isSet("condyForLambda");
-        Source source = Source.instance(context);
-        allowCondyForLambda = source.allowCondyForLambda();
     }
     // </editor-fold>
 
@@ -1090,51 +1085,7 @@
             }
         }
 
-        return doConstantFold &&
-                condyForLambda &&
-                allowCondyForLambda &&
-                !context.needsAltMetafactory() &&
-                indy_args.isEmpty() ?
-                makeCondy(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, tree.type, indy_args, samSym.name) :
-                makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
-    }
-
-    private final boolean doConstantFold;
-    /* this extra flag should be temporary and used as long as it's not possible to do the build
-     * due to the lack of support for condy in the current version of ASM present in the build
-     */
-    private final boolean condyForLambda;
-    private final boolean allowCondyForLambda;
-
-    private JCExpression makeCondy(DiagnosticPosition pos, Type site, Name bsmName,
-            List<Object> staticArgs, Type interfaceType, List<JCExpression> indyArgs,
-            Name methName) {
-        int prevPos = make.pos;
-        try {
-            make.at(pos);
-            List<Type> bsm_staticArgs = List.of(syms.methodHandlesLookupType,
-                    syms.stringType,
-                    syms.classType).appendList(bsmStaticArgToTypes(staticArgs));
-
-            Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
-                    bsmName, bsm_staticArgs, List.nil());
-
-            DynamicFieldSymbol dynSym = new DynamicFieldSymbol(methName,
-                    syms.noSymbol,
-                    bsm.isStatic() ?
-                        ClassFile.REF_invokeStatic :
-                        ClassFile.REF_invokeVirtual,
-                    (MethodSymbol)bsm,
-                    interfaceType,
-                    staticArgs.toArray());
-
-            JCIdent ident = make.Ident(dynSym);
-            ident.type = interfaceType;
-
-            return ident;
-        } finally {
-            make.at(prevPos);
-        }
+        return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
     }
 
     /**
@@ -1147,7 +1098,7 @@
         int prevPos = make.pos;
         try {
             make.at(pos);
-            List<Type> bsm_staticArgs = List.of(syms.methodHandlesLookupType,
+            List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                     syms.stringType,
                     syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));
 
@@ -1495,7 +1446,7 @@
                         void visitSymbol(Symbol sym) {
                             if (sym.kind == VAR &&
                                     sym.owner.kind == MTH &&
-                                    ((VarSymbol)sym).getConstValue(attrEnv.enclClass.sym, syms) == null) {
+                                    ((VarSymbol)sym).getConstValue() == null) {
                                 TranslationContext<?> localContext = context();
                                 while (localContext != null) {
                                     if (localContext.tree.getTag() == LAMBDA) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Sep 29 14:38:51 2017 -0700
@@ -40,10 +40,8 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
-import com.sun.tools.javac.code.Symbol.VarSymbol.ConstantKind;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
 
 import com.sun.tools.javac.jvm.Target;
 import com.sun.tools.javac.tree.EndPosTable;
@@ -96,7 +94,6 @@
     private final Types types;
     private final boolean debugLower;
     private final PkgInfo pkginfoOpt;
-    private final boolean doConstantFold;
 
     protected Lower(Context context) {
         context.put(lowerKey, this);
@@ -124,10 +121,6 @@
         Options options = Options.instance(context);
         debugLower = options.isSet("debuglower");
         pkginfoOpt = PkgInfo.get(options);
-        doConstantFold = options.isSet("doConstantFold");
-        if (doConstantFold) {
-            specialConstUtils = new SpecialConstantUtils(context);
-        }
     }
 
     /** The currently enclosing class.
@@ -319,7 +312,7 @@
                     sym = proxies.findFirst(proxyName(sym.name));
                 if (sym != null && sym.owner == owner) {
                     VarSymbol v = (VarSymbol)sym;
-                    if (v.getConstValue(clazz, syms) == null) {
+                    if (v.getConstValue() == null) {
                         addFreeVar(v);
                     }
                 } else {
@@ -1085,7 +1078,7 @@
         while (sym.kind == VAR && sym.owner.kind == MTH &&
             sym.owner.enclClass() != currentClass) {
             // A constant is replaced by its constant value.
-            Object cv = ((VarSymbol)sym).getConstValue(currentClass, syms);
+            Object cv = ((VarSymbol)sym).getConstValue();
             if (cv != null) {
                 make.at(tree.pos);
                 return makeLit(sym.type, cv);
@@ -1144,7 +1137,7 @@
 
                     // Constants are replaced by their constant value.
                     if (sym.kind == VAR) {
-                        Object cv = ((VarSymbol)sym).getConstValue(attrEnv.enclClass.sym, syms);
+                        Object cv = ((VarSymbol)sym).getConstValue();
                         if (cv != null) {
                             addPrunedInfo(tree);
                             return makeLit(sym.type, cv);
@@ -1490,15 +1483,7 @@
     }
 //where
         JCExpression loadFreevar(DiagnosticPosition pos, VarSymbol v) {
-            JCIdent ident = make.at(pos).Ident(v);
-            /** this code to update the type of the ident is not needed if we later decide that
-             *  local anonymous inner classes can safely inline local special constants
-             */
-            Object cv = v.getConstValue(currentClass, syms);
-            if (cv != null) {
-                ident.type = ident.type.constType(cv);
-            }
-            return access(v, ident, null, false);
+            return access(v, make.at(pos).Ident(v), null, false);
         }
 
     /** Construct a tree simulating the expression {@code C.this}.
@@ -1924,32 +1909,25 @@
     }
 
     private JCExpression classOfType(Type type, DiagnosticPosition pos) {
-        if (!doConstantFold) {
-            switch (type.getTag()) {
-            case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
-            case DOUBLE: case BOOLEAN: case VOID:
-                // replace with <BoxedClass>.TYPE
-                ClassSymbol c = types.boxedClass(type);
-                Symbol typeSym =
-                    rs.accessBase(
-                        rs.findIdentInType(attrEnv, c.type, names.TYPE, KindSelector.VAR),
-                        pos, c.type, names.TYPE, true);
-                if (typeSym.kind == VAR)
-                    ((VarSymbol)typeSym).getConstValue(); // ensure initializer is evaluated
-                return make.QualIdent(typeSym);
-            case CLASS: case ARRAY:
-                    VarSymbol sym = new VarSymbol(
-                            STATIC | PUBLIC | FINAL, names._class,
-                            syms.classType, type.tsym);
-                    return make_at(pos).Select(make.Type(type), sym);
-            default:
-                throw new AssertionError();
-            }
-        } else {
-            VarSymbol sym = new VarSymbol(
-                    STATIC | PUBLIC | FINAL, names._class,
-                    syms.classType, type.tsym);
-            return make_at(pos).Select(make.Type(type), sym);
+        switch (type.getTag()) {
+        case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
+        case DOUBLE: case BOOLEAN: case VOID:
+            // replace with <BoxedClass>.TYPE
+            ClassSymbol c = types.boxedClass(type);
+            Symbol typeSym =
+                rs.accessBase(
+                    rs.findIdentInType(attrEnv, c.type, names.TYPE, KindSelector.VAR),
+                    pos, c.type, names.TYPE, true);
+            if (typeSym.kind == VAR)
+                ((VarSymbol)typeSym).getConstValue(); // ensure initializer is evaluated
+            return make.QualIdent(typeSym);
+        case CLASS: case ARRAY:
+                VarSymbol sym = new VarSymbol(
+                        STATIC | PUBLIC | FINAL, names._class,
+                        syms.classType, type.tsym);
+                return make_at(pos).Select(make.Type(type), sym);
+        default:
+            throw new AssertionError();
         }
     }
 
@@ -1999,10 +1977,10 @@
                                                             List.nil());
             JCClassDecl containerDef = classDef(container);
             make_at(containerDef.pos());
-            JCExpression qualifierExpr = !doConstantFold ? classOfType(types.erasure(outermostClass.type), containerDef.pos()) :
-                    classOfType(types.erasure(outermostClass.type), containerDef.pos())
-                            .setType(types.erasure(syms.classType).constType(outermostClass.type.tsym));
-            JCExpression notStatus = makeUnary(NOT, make.App(make.Select(qualifierExpr, desiredAssertionStatusSym)));
+            JCExpression notStatus = makeUnary(NOT, make.App(make.Select(
+                    classOfType(types.erasure(outermostClass.type),
+                                containerDef.pos()),
+                    desiredAssertionStatusSym)));
             JCVariableDecl assertDisabledDef = make.VarDef(assertDisabledSym,
                                                    notStatus);
             containerDef.defs = containerDef.defs.prepend(assertDisabledDef);
@@ -2315,10 +2293,8 @@
             tree.extending = make.Type(types.supertype(tree.type));
 
         // classOfType adds a cache field to tree.defs
-        JCExpression e_class = !doConstantFold ?
-                classOfType(tree.sym.type, tree.pos()).setType(types.erasure(syms.classType)) :
-                classOfType(tree.sym.type, tree.pos()).setType(types.erasure(syms.classType)
-                        .constType(tree.sym.type.tsym));
+        JCExpression e_class = classOfType(tree.sym.type, tree.pos()).
+            setType(types.erasure(syms.classType));
 
         // process each enumeration constant, adding implicit constructor parameters
         int nextOrdinal = 0;
@@ -2874,8 +2850,6 @@
         result = tree;
     }
 
-    SpecialConstantUtils specialConstUtils;
-
     List<JCExpression> boxArgs(List<Type> parameters, List<JCExpression> _args, Type varargsElement) {
         List<JCExpression> args = _args;
         if (parameters.isEmpty()) return args;
@@ -3149,7 +3123,7 @@
 
         tree.arg = boxIfNeeded(translate(tree.arg, tree), tree.type);
 
-        if (tree.hasTag(NOT) && tree.arg.type.hasIntrinsicConstValue()) {
+        if (tree.hasTag(NOT) && tree.arg.type.constValue() != null) {
             tree.type = cfolder.fold1(bool_not, tree.arg.type);
         }
 
@@ -3355,9 +3329,6 @@
         }
 
     public void visitVarDef(JCVariableDecl tree) {
-        if (doConstantFold) {
-            checkSpecialConstants(tree);
-        }
         MethodSymbol oldMethodSym = currentMethodSym;
         tree.mods = translate(tree.mods);
         tree.vartype = translate(tree.vartype);
@@ -3373,18 +3344,6 @@
         currentMethodSym = oldMethodSym;
     }
 
-    void checkSpecialConstants(JCVariableDecl tree) {
-        if (tree.sym.getConstKind() == ConstantKind.PARTIAL
-                && tree.init.type.constValue(currentClass, syms) == null) {
-            Object value = tree.sym.getConstValue();
-            SpecialConstant sconstant = (SpecialConstant)value;
-            // the compiler will issue an error for all special constants but class literals
-            if (!(sconstant.value instanceof ClassSymbol)) {
-                log.error(tree.pos(), Errors.InitializerMustBeConstant);
-            }
-        }
-    }
-
     public void visitBlock(JCBlock tree) {
         MethodSymbol oldMethodSym = currentMethodSym;
         if (currentMethodSym == null) {
@@ -3672,15 +3631,17 @@
             TreeInfo.name(tree.selected) == names._super &&
             !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type.tsym, currentClass);
         tree.selected = translate(tree.selected);
-        if (!doConstantFold && tree.name == names._class) {
+        if (tree.name == names._class) {
             result = classOf(tree.selected);
-        } else if (tree.name == names._super &&
+        }
+        else if (tree.name == names._super &&
                 types.isDirectSuperInterface(tree.selected.type.tsym, currentClass)) {
             //default super call!! Not a classic qualified super call
             TypeSymbol supSym = tree.selected.type.tsym;
             Assert.checkNonNull(types.asSuper(currentClass.type, supSym));
             result = tree;
-        } else if (tree.name == names._this || tree.name == names._super) {
+        }
+        else if (tree.name == names._this || tree.name == names._super) {
             result = makeThis(tree.pos(), tree.selected.type.tsym);
         }
         else
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Sep 29 14:38:51 2017 -0700
@@ -398,9 +398,6 @@
         public void visitIdent(JCIdent that) {}
 
         @Override
-        public void visitTypeIdent(JCPrimitiveTypeTree that) { }
-
-        @Override
         public void visitSelect(JCFieldAccess tree) {
             tree.selected.accept(this);
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Sep 29 14:38:51 2017 -0700
@@ -145,11 +145,6 @@
         inapplicableMethodException = new InapplicableMethodException(diags);
 
         allowModules = source.allowModules();
-
-        doConstantFold = options.isSet("doConstantFold");
-        if (doConstantFold) {
-            specialConstUtils = new SpecialConstantUtils(context);
-        }
     }
 
     /** error symbols, which are returned when resolution fails
@@ -2616,22 +2611,7 @@
                         return findFun(env, name, argtypes, typeargtypes,
                                 phase.isBoxingRequired(),
                                 phase.isVarargsRequired());
-                    }
-                    @Override
-                    Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
-                        if (sym.kind.isResolutionError()) {
-                            sym = super.access(env, pos, location, sym);
-                        } else {
-                            MethodSymbol msym = (MethodSymbol)sym;
-                            if (doConstantFold &&
-                                    (specialConstUtils.isIntrinsicsIndy(msym))) {
-                                sym.flags_field |= SIGNATURE_POLYMORPHIC;
-                                return findPolymorphicSignatureInstance(env, sym, argtypes);
-                            }
-                        }
-                        return sym;
-                    }
-                });
+                    }});
     }
 
     /** Resolve a qualified method identifier
@@ -2653,19 +2633,11 @@
                                   List<Type> typeargtypes) {
         return resolveQualifiedMethod(new MethodResolutionContext(), pos, env, location, site, name, argtypes, typeargtypes);
     }
-    Symbol resolveQualifiedMethod(MethodResolutionContext resolveContext,
+    private Symbol resolveQualifiedMethod(MethodResolutionContext resolveContext,
                                   DiagnosticPosition pos, Env<AttrContext> env,
                                   Symbol location, Type site, Name name, List<Type> argtypes,
                                   List<Type> typeargtypes) {
-        return resolveQualifiedMethod(resolveContext, pos, env, location, site, name,
-                argtypes, typeargtypes, MethodResolutionPhase.VARARITY);
-    }
-    Symbol resolveQualifiedMethod(MethodResolutionContext resolveContext,
-                                  DiagnosticPosition pos, Env<AttrContext> env,
-                                  Symbol location, Type site, Name name, List<Type> argtypes,
-                                  List<Type> typeargtypes,
-                                  MethodResolutionPhase maxPhase) {
-        return lookupMethod(env, pos, location, resolveContext, new BasicLookupHelper(name, site, argtypes, typeargtypes, maxPhase) {
+        return lookupMethod(env, pos, location, resolveContext, new BasicLookupHelper(name, site, argtypes, typeargtypes) {
             @Override
             Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
                 return findMethod(env, site, name, argtypes, typeargtypes,
@@ -2678,10 +2650,7 @@
                     sym = super.access(env, pos, location, sym);
                 } else if (allowMethodHandles) {
                     MethodSymbol msym = (MethodSymbol)sym;
-                    if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0 ||
-                        doConstantFold &&
-                        specialConstUtils.isIntrinsicsIndy(msym)) {
-                        sym.flags_field |= SIGNATURE_POLYMORPHIC;
+                    if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0) {
                         return findPolymorphicSignatureInstance(env, sym, argtypes);
                     }
                 }
@@ -2690,9 +2659,6 @@
         });
     }
 
-    private boolean doConstantFold;
-    private SpecialConstantUtils specialConstUtils;
-
     /** Find or create an implicit method of exactly the given type (after erasure).
      *  Searches in a side table, not the main scope of the site.
      *  This emulates the lookup process required by JSR 292 in JVM.
@@ -4641,7 +4607,7 @@
         }
     }
 
-    public enum MethodResolutionPhase {
+    enum MethodResolutionPhase {
         BASIC(false, false),
         BOX(true, false),
         VARARITY(true, true) {
@@ -4722,7 +4688,7 @@
 
         MethodCheck methodCheck = resolveMethodCheck;
 
-        boolean internalResolution = false;
+        private boolean internalResolution = false;
         private DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE;
 
         void addInapplicableCandidate(Symbol sym, JCDiagnostic details) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Sep 29 14:38:51 2017 -0700
@@ -81,9 +81,6 @@
 
     /** Switch: are default methods supported? */
     private final boolean allowInterfaceBridges;
-    /** Switch: is special constant folding allowed */
-    private final boolean doConstantFold;
-    private final SpecialConstantUtils specialConstantUtils;
 
     protected TransTypes(Context context) {
         context.put(transTypesKey, this);
@@ -101,9 +98,6 @@
         allowGraphInference = source.allowGraphInference();
         annotate = Annotate.instance(context);
         attr = Attr.instance(context);
-        Options options = Options.instance(context);
-        doConstantFold = options.isSet("doConstantFold");
-        specialConstantUtils = new SpecialConstantUtils(context);
     }
 
     /** A hashtable mapping bridge methods to the pair of methods they bridge.
@@ -556,14 +550,10 @@
     }
 
     public void visitVarDef(JCVariableDecl tree) {
-        Object constValue = tree.init != null ? tree.init.type.constValue() : null;
         tree.vartype = translate(tree.vartype, null);
         tree.init = translate(tree.init, tree.sym.erasure(types));
         tree.type = erasure(tree.type);
         result = tree;
-        if (doConstantFold && constValue != null && tree.init.type.constValue() == null) {
-            tree.init.type = tree.type.constType(constValue);
-        }
     }
 
     public void visitDoLoop(JCDoWhileLoop tree) {
@@ -699,15 +689,9 @@
             }
         tree.args = translateArgs(tree.args, argtypes, tree.varargsElement);
 
-        Object constValue = tree.type.constValue();
         tree.type = types.erasure(tree.type);
         // Insert casts of method invocation results as needed.
-        boolean isCondyLDC = specialConstantUtils.isIntrinsicsLDCInvocation(TreeInfo.symbol(tree.meth)) &&
-                    tree.args.head.type.tsym == syms.dynamicConstantRefType.tsym;
-        result = retype(tree, isCondyLDC ? tree.meth.type.getReturnType() : mt.getReturnType(), pt);
-        if (doConstantFold && constValue != null && tree.type.constValue() == null) {
-            tree.type = tree.type.constType(constValue);
-        }
+        result = retype(tree, mt.getReturnType(), pt);
     }
 
     public void visitNewClass(JCNewClass tree) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Fri Sep 29 14:38:51 2017 -0700
@@ -84,7 +84,6 @@
     public final static int CONSTANT_NameandType = 12;
     public final static int CONSTANT_MethodHandle = 15;
     public final static int CONSTANT_MethodType = 16;
-    public final static int CONSTANT_ConstantDynamic = 17;
     public final static int CONSTANT_InvokeDynamic = 18;
     public final static int CONSTANT_Module = 19;
     public final static int CONSTANT_Package = 20;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Sep 29 14:38:51 2017 -0700
@@ -405,7 +405,6 @@
             case CONSTANT_NameandType:
             case CONSTANT_Integer:
             case CONSTANT_Float:
-            case CONSTANT_ConstantDynamic:
             case CONSTANT_InvokeDynamic:
                 bp = bp + 4;
                 break;
@@ -481,7 +480,6 @@
         case CONSTANT_MethodType:
             skipBytes(3);
             break;
-        case CONSTANT_ConstantDynamic:
         case CONSTANT_InvokeDynamic:
             skipBytes(5);
             break;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Sep 29 14:38:51 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,7 @@
 import com.sun.tools.javac.jvm.Pool.Method;
 import com.sun.tools.javac.jvm.Pool.MethodHandle;
 import com.sun.tools.javac.jvm.Pool.Variable;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.util.*;
 
 import static com.sun.tools.javac.code.Flags.*;
@@ -145,9 +146,6 @@
     /** The name table. */
     private final Names names;
 
-    /** The symbol table. */
-    private final Symtab syms;
-
     /** Access to files. */
     private final JavaFileManager fileManager;
 
@@ -176,7 +174,6 @@
 
         log = Log.instance(context);
         names = Names.instance(context);
-        syms = Symtab.instance(context);
         options = Options.instance(context);
         target = Target.instance(context);
         source = Source.instance(context);
@@ -398,26 +395,26 @@
                     //invokedynamic
                     DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m;
                     MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types);
-                    DynamicMethod.BootstrapMethodsValue val = writeDynSymbol(dynSym, handle);
+                    DynamicMethod.BootstrapMethodsKey key = new DynamicMethod.BootstrapMethodsKey(dynSym, types);
+
+                    // Figure out the index for existing BSM; create a new BSM if no key
+                    DynamicMethod.BootstrapMethodsValue val = bootstrapMethods.get(key);
+                    if (val == null) {
+                        int index = bootstrapMethods.size();
+                        val = new DynamicMethod.BootstrapMethodsValue(handle, index);
+                        bootstrapMethods.put(key, val);
+                    }
+
+                    //init cp entries
+                    pool.put(names.BootstrapMethods);
+                    pool.put(handle);
+                    for (Object staticArg : dynSym.staticArgs) {
+                        pool.put(staticArg);
+                    }
                     poolbuf.appendByte(CONSTANT_InvokeDynamic);
                     poolbuf.appendChar(val.index);
                     poolbuf.appendChar(pool.put(nameType(dynSym)));
                 }
-            } else if (value instanceof Pool.ConstantDynamic) {
-                Pool.ConstantDynamic cd = (Pool.ConstantDynamic)value;
-                MethodHandle handle = cd.bsm;
-                DynamicMethodSymbol dynSym = new DynamicMethodSymbol(
-                        handle.refSym.name,
-                        syms.noSymbol,
-                        handle.refKind,
-                        (MethodSymbol)handle.refSym,
-                        handle.refSym.type,
-                        cd.args);
-                DynamicMethod.BootstrapMethodsValue val = writeDynSymbol(dynSym, handle);
-                poolbuf.appendByte(CONSTANT_ConstantDynamic);
-                poolbuf.appendChar(val.index);
-                NameAndType nt = new NameAndType(cd.name, cd.type, cd.types);
-                poolbuf.appendChar(pool.put(nt));
             } else if (value instanceof VarSymbol) {
                 VarSymbol v = (VarSymbol)value;
                 poolbuf.appendByte(CONSTANT_Fieldref);
@@ -495,26 +492,6 @@
         putChar(poolbuf, poolCountIdx, pool.pp);
     }
 
-    DynamicMethod.BootstrapMethodsValue writeDynSymbol(DynamicMethodSymbol dynSym, MethodHandle handle) {
-        DynamicMethod.BootstrapMethodsKey key = new DynamicMethod.BootstrapMethodsKey(dynSym, types);
-
-        // Figure out the index for existing BSM; create a new BSM if no key
-        DynamicMethod.BootstrapMethodsValue val = bootstrapMethods.get(key);
-        if (val == null) {
-            int index = bootstrapMethods.size();
-            val = new DynamicMethod.BootstrapMethodsValue(handle, index);
-            bootstrapMethods.put(key, val);
-        }
-
-        //init cp entries
-        pool.put(names.BootstrapMethods);
-        pool.put(handle);
-        for (Object staticArg : dynSym.staticArgs) {
-            pool.put(staticArg);
-        }
-        return val;
-    }
-
     /** Given a symbol, return its name-and-type.
      */
     NameAndType nameType(Symbol sym) {
@@ -1152,7 +1129,7 @@
         databuf.appendChar(pool.put(typeSig(v.erasure(types))));
         int acountIdx = beginAttrs();
         int acount = 0;
-        if (!pool.varSymNeedsInitializer(v)) {
+        if (v.getConstValue() != null) {
             int alenIdx = writeAttr(names.ConstantValue);
             databuf.appendChar(pool.put(v.getConstValue()));
             endAttr(alenIdx);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java	Fri Sep 29 14:38:51 2017 -0700
@@ -29,7 +29,6 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Types.UniqueType;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
-import com.sun.tools.javac.jvm.Pool.ConstantDynamic;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -921,7 +920,6 @@
         if (o instanceof ClassSymbol) return syms.classType;
         if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
         if (o instanceof UniqueType) return typeForPool(((UniqueType)o).type);
-        if (o instanceof Pool.ConstantDynamic) return ((Pool.ConstantDynamic)o).type;
         if (o instanceof Type) {
             Type ty = (Type) o;
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Sep 29 14:38:51 2017 -0700
@@ -25,9 +25,7 @@
 
 package com.sun.tools.javac.jvm;
 
-
 import com.sun.tools.javac.tree.TreeInfo.PosKind;
-import com.sun.tools.javac.code.Symbol.VarSymbol.ConstantKind;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
@@ -35,12 +33,10 @@
 import com.sun.tools.javac.code.Attribute.TypeCompound;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.comp.*;
-import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.tree.*;
 
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
 import com.sun.tools.javac.jvm.Code.*;
 import com.sun.tools.javac.jvm.Items.*;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
@@ -131,10 +127,6 @@
         debugCode = options.isSet("debug.code");
         allowBetterNullChecks = target.hasObjects();
         pool = new Pool(types);
-        doConstantFold = options.isSet("doConstantFold");
-        if (doConstantFold) {
-            specialConstUtils = new SpecialConstantUtils(context);
-        }
 
         // ignore cldc because we cannot have both stackmap formats
         this.stackMap = StackMapFormat.JSR202;
@@ -148,7 +140,6 @@
     private final boolean genCrt;
     private final boolean debugCode;
     private final boolean allowBetterNullChecks;
-    private final boolean doConstantFold;
 
     /** Code buffer, set by genMethod.
      */
@@ -447,7 +438,7 @@
                         initCode.append(init);
                         endPosTable.replaceTree(vdef, init);
                         initTAs.addAll(getAndRemoveNonFieldTAs(sym));
-                    } else if (pool.varSymNeedsInitializer(sym)) {
+                    } else if (sym.getConstValue() == null) {
                         // Initialize class (static) variables only if
                         // they are not compile-time constants.
                         JCStatement init = make.at(vdef.pos).
@@ -816,45 +807,11 @@
     public Item genExpr(JCTree tree, Type pt) {
         Type prevPt = this.pt;
         try {
-            Object constVal = tree.type.constValue(env.enclClass.sym, syms);
-            /* X.class is special cased in the compiler, the logic below means that if a constant value
-             * possibly from a special constant is not a class symbol, which is how X.class is represented
-             * as a special constant, or if it is a class symbol but the target type is not java.lang.Class
-             * then we want to call the constValue method telling it that it's being invoked from code
-             * generation. If there is a special constant on the other side and that special constant
-             * is supposed to be ldc'ed then we will get a value != null, in other case no ldc will
-             * be generated
-             */
-            if (!(tree.hasTag(SELECT) && ((JCFieldAccess)tree).name == names._class)) {
-                constVal = foldableValueForType(tree.type);
-            }
-            if (constVal == null && doConstantFold && specialConstUtils.isIntrinsicsLDCInvocation(tree)) {
-                log.error(tree.pos(), Errors.IntrinsicsLdcMustHaveConstantArg);
-                nerrs++;
-            }
-            if (constVal != null) {
+            if (tree.type.constValue() != null) {
                 // Short circuit any expressions which are constants
                 tree.accept(classReferenceVisitor);
-                checkStringConstant(tree.pos(), constVal);
-                if (!doConstantFold) {
-                    result = items.makeImmediateItem(tree.type, tree.type.constValue());
-                } else {
-                    if (constVal instanceof ClassSymbol &&
-                            ((ClassSymbol)constVal).type.isPrimitiveOrVoid()) {
-                        Type t = ((ClassSymbol)constVal).type;
-                        Symbol f = rs.resolveInternalField(tree, attrEnv, types.boxedClass(t).type, names.TYPE);
-                        result = items.makeStaticItem(f);
-                    } else {
-                        Object convertedConstant = specialConstUtils.convertConstant(tree, attrEnv, constVal, env.enclClass.sym.packge().modle);
-                        if (specialConstUtils.isPrimitiveClassRef(constVal)) {
-                            result = items.makeStaticItem((Symbol)convertedConstant);
-                        } else {
-                            result = items.makeImmediateItem(tree.type, convertedConstant);
-                        }
-                    }
-                }
-            } else if (doConstantFold && specialConstUtils.isIntrinsicsIndy(tree)) {
-                generateIndy((JCMethodInvocation)tree);
+                checkStringConstant(tree.pos(), tree.type.constValue());
+                result = items.makeImmediateItem(tree.type, tree.type.constValue());
             } else {
                 this.pt = pt;
                 tree.accept(this);
@@ -869,96 +826,6 @@
         }
     }
 
-    private SpecialConstantUtils specialConstUtils;
-
-    void generateIndy(JCMethodInvocation tree) {
-        // the first argument is an indy descriptor
-        Pool.MethodHandle mHandle = getIndyMHandle(tree);
-        if (mHandle == null) {
-            // nothing to do, the indy is erroneous, so let's try to finish as nicely as possible
-            code.state.stacksize++; // just to avoid a compiler crash
-        } else {
-            List<JCExpression> tmpArgs = tree.args;
-            Object constant = tmpArgs.head.type.constValue(env.enclClass.sym, syms);
-            tmpArgs = tmpArgs.tail;
-            String invocationName = (String)tmpArgs.head.type.constValue();
-            // now we can skip the first argument and focus on the rest which is an Object[]
-            tmpArgs = tmpArgs.tail;
-            ListBuffer<Type> arguments = new ListBuffer<>();
-            for (JCExpression tmpArg : tmpArgs) {
-                    arguments.add(tmpArg.type);
-                    genExpr(tmpArg, tmpArg.type).load();
-            }
-            // Convert BSM args
-            Object[] bsmArgs = (Object[])specialConstUtils.invokeReflectiveMethod(specialConstUtils.bootstrapSpecifierClass, constant, "arguments");
-            Object[] convertedBsmArgs = specialConstUtils.convertConstants(tree, attrEnv, bsmArgs, env.enclClass.sym.packge().modle, true);
-            MethodType mType = new MethodType(arguments.toList(), tree.type, List.nil(), syms.methodClass);
-            Item item = items.makeDynamicItem(new DynamicMethodSymbol(
-                    names.fromString(invocationName),
-                    syms.noSymbol,
-                    mHandle.refKind,
-                    (MethodSymbol)mHandle.refSym,
-                    mType,
-                    convertedBsmArgs));
-            result = item.invoke();
-        }
-    }
-
-    /* returns the internal method handle for the given indy invocation.
-     * Returns null if any error is found.
-     */
-    Pool.MethodHandle getIndyMHandle(JCMethodInvocation tree) {
-        // the first argument is an indy descriptor
-        List<JCExpression> tmpArgs = tree.args;
-        Object constant = tmpArgs.head.type.constValue(env.enclClass.sym, syms);
-        if (constant == null) {
-            log.error(tree.args.head.pos(), Errors.IntrinsicsIndyMustHaveConstantArg);
-            nerrs++;
-        }
-        tmpArgs = tmpArgs.tail;
-        String invocationName = (String)tmpArgs.head.type.constValue();
-        if (invocationName == null) {
-            log.error(tmpArgs.head.pos(), Errors.IntrinsicsIndyMustHaveConstantArg);
-            nerrs++;
-            return null;
-        }
-        if (invocationName.isEmpty()) {
-            log.error(tmpArgs.head.pos(), Errors.InvocationNameCannotBeEmpty);
-            nerrs++;
-            return null;
-        }
-        if (constant != null) {
-            Object mh = specialConstUtils.invokeReflectiveMethod(specialConstUtils.bootstrapSpecifierClass, constant, "method");
-            Pool.MethodHandle mHandle = (Pool.MethodHandle)specialConstUtils
-                    .convertConstant(tree, attrEnv, mh, env.enclClass.sym.packge().modle);
-            boolean correct = false;
-            if (mHandle.refKind == 6 || mHandle.refKind == 8) {
-                MethodSymbol ms = (MethodSymbol)mHandle.refSym;
-                MethodType mt = (MethodType)ms.type;
-                correct = (mt.argtypes.size() >= 3 &&
-                    mt.argtypes.head.tsym == syms.methodHandlesLookupType.tsym &&
-                    mt.argtypes.tail.head.tsym == syms.stringType.tsym &&
-                    mt.argtypes.tail.tail.head.tsym == syms.methodTypeType.tsym);
-            }
-            if (!correct) {
-                log.error(tree.args.head.pos(), Errors.MethodHandleNotSuitableIndy(mHandle.refSym.type));
-                nerrs++;
-            } else {
-                return mHandle;
-            }
-        }
-        return null;
-    }
-
-    private Object foldableValueForType(Type type) {
-        Object val = type.constValue();
-        if (val instanceof SpecialConstant) {
-            SpecialConstant sc = (SpecialConstant)val;
-            val = sc.generateLDC() ? sc.getConstantValue(env.enclClass.sym) : null;
-        }
-        return val;
-    }
-
     /** Derived visitor method: generate code for a list of method arguments.
      *  @param trees    The argument expressions to be visited.
      *  @param pts      The expression's expected types (i.e. the formal parameter
@@ -1142,11 +1009,8 @@
         VarSymbol v = tree.sym;
         code.newLocal(v);
         if (tree.init != null) {
-            Object constValue = v.getConstValue(env.enclClass.sym, syms);
-            checkStringConstant(tree.init.pos(), constValue);
-            if (constValue == null ||
-                    varDebugInfo ||
-                    shouldGenerateInit(v, constValue)) {
+            checkStringConstant(tree.init.pos(), v.getConstValue());
+            if (v.getConstValue() == null || varDebugInfo) {
                 Assert.check(letExprDepth != 0 || code.state.stacksize == 0);
                 genExpr(tree.init, v.erasure(types)).load();
                 items.makeLocalItem(v).store();
@@ -1156,14 +1020,6 @@
         checkDimension(tree.pos(), v.type);
     }
 
-    private boolean shouldGenerateInit(VarSymbol v, Object constValue) {
-        SpecialConstant sc = v.getConstKind() == ConstantKind.PARTIAL ? (SpecialConstant)v.getConstValue() : null;
-        return doConstantFold &&
-                    constValue != null &&
-                    v.getConstKind() == ConstantKind.PARTIAL &&
-                    !sc.generateLDC();
-    }
-
     public void visitSkip(JCSkip tree) {
     }
 
@@ -1961,7 +1817,7 @@
                 l instanceof LocalItem &&
                 tree.lhs.type.getTag().isSubRangeOf(INT) &&
                 tree.rhs.type.getTag().isSubRangeOf(INT) &&
-                tree.rhs.type.hasIntrinsicConstValue()) {
+                tree.rhs.type.constValue() != null) {
                 int ival = ((Number) tree.rhs.type.constValue()).intValue();
                 if (tree.hasTag(MINUS_ASG)) ival = -ival;
                 ((LocalItem)l).incr(ival);
@@ -2186,10 +2042,10 @@
                 res = items.makeMemberItem(sym, true);
             }
             result = res;
-        } else if (isInvokeDynamic(sym) || isLambdaCondy(sym)) {
-            result = items.makeDynamicItem(sym);
         } else if (sym.kind == VAR && sym.owner.kind == MTH) {
             result = items.makeLocalItem((VarSymbol)sym);
+        } else if (isInvokeDynamic(sym)) {
+            result = items.makeDynamicItem(sym);
         } else if ((sym.flags() & STATIC) != 0) {
             if (!isAccessSuper(env.enclMethod))
                 sym = binaryQualifier(sym, env.enclClass.type);
@@ -2204,13 +2060,11 @@
     public void visitSelect(JCFieldAccess tree) {
         Symbol sym = tree.sym;
 
-        if (!doConstantFold) {
-            if (tree.name == names._class) {
-                code.emitLdc(makeRef(tree.pos(), tree.selected.type));
-                result = items.makeStackItem(pt);
-                return;
-            }
-        }
+        if (tree.name == names._class) {
+            code.emitLdc(makeRef(tree.pos(), tree.selected.type));
+            result = items.makeStackItem(pt);
+            return;
+       }
 
         Symbol ssym = TreeInfo.symbol(tree.selected);
 
@@ -2226,7 +2080,7 @@
             ? items.makeSuperItem()
             : genExpr(tree.selected, tree.selected.type);
 
-        if (sym.kind == VAR && ((VarSymbol) sym).getConstValue(env.enclClass.sym, syms) != null) {
+        if (sym.kind == VAR && ((VarSymbol) sym).getConstValue() != null) {
             // We are seeing a variable that is constant but its selecting
             // expression is not.
             if ((sym.flags() & STATIC) != 0) {
@@ -2238,7 +2092,7 @@
                 genNullCheck(tree.selected);
             }
             result = items.
-                makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue(env.enclClass.sym, syms));
+                makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
         } else {
             if (isInvokeDynamic(sym)) {
                 result = items.makeDynamicItem(sym);
@@ -2270,12 +2124,6 @@
         return sym.kind == MTH && ((MethodSymbol)sym).isDynamic();
     }
 
-    public boolean isLambdaCondy(Symbol sym) {
-        return sym.kind == VAR &&
-                sym instanceof DynamicFieldSymbol &&
-                ((DynamicFieldSymbol)sym).isDynamic();
-    }
-
     public void visitLiteral(JCLiteral tree) {
         if (tree.type.hasTag(BOT)) {
             code.emitop0(aconst_null);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java	Fri Sep 29 14:38:51 2017 -0700
@@ -26,7 +26,6 @@
 package com.sun.tools.javac.jvm;
 
 import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Kinds.Kind;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.jvm.Code.*;
@@ -473,11 +472,8 @@
         }
 
         Item load() {
-            Assert.check(member.kind == Kind.VAR);
-            Type type = member.erasure(types);
-            int rescode = Code.typecode(type);
-            code.emitLdc(pool.put(member));
-            return stackItem[rescode];
+            assert false;
+            return null;
         }
 
         void store() {
@@ -485,7 +481,7 @@
         }
 
         Item invoke() {
-            Assert.check(member.kind == Kind.MTH);
+            // assert target.hasNativeInvokeDynamic();
             MethodType mtype = (MethodType)member.erasure(types);
             int rescode = Code.typecode(mtype.restype);
             code.emitInvokedynamic(pool.put(member), mtype);
@@ -581,49 +577,45 @@
         }
 
         Item load() {
-            if (value instanceof Pool.ConstantDynamic) {
+            switch (typecode) {
+            case INTcode: case BYTEcode: case SHORTcode: case CHARcode:
+                int ival = ((Number)value).intValue();
+                if (-1 <= ival && ival <= 5)
+                    code.emitop0(iconst_0 + ival);
+                else if (Byte.MIN_VALUE <= ival && ival <= Byte.MAX_VALUE)
+                    code.emitop1(bipush, ival);
+                else if (Short.MIN_VALUE <= ival && ival <= Short.MAX_VALUE)
+                    code.emitop2(sipush, ival);
+                else
+                    ldc();
+                break;
+            case LONGcode:
+                long lval = ((Number)value).longValue();
+                if (lval == 0 || lval == 1)
+                    code.emitop0(lconst_0 + (int)lval);
+                else
+                    ldc();
+                break;
+            case FLOATcode:
+                float fval = ((Number)value).floatValue();
+                if (isPosZero(fval) || fval == 1.0 || fval == 2.0)
+                    code.emitop0(fconst_0 + (int)fval);
+                else {
+                    ldc();
+                }
+                break;
+            case DOUBLEcode:
+                double dval = ((Number)value).doubleValue();
+                if (isPosZero(dval) || dval == 1.0)
+                    code.emitop0(dconst_0 + (int)dval);
+                else
+                    ldc();
+                break;
+            case OBJECTcode:
                 ldc();
-            } else {
-                switch (typecode) {
-                case INTcode: case BYTEcode: case SHORTcode: case CHARcode:
-                    int ival = ((Number)value).intValue();
-                    if (-1 <= ival && ival <= 5)
-                        code.emitop0(iconst_0 + ival);
-                    else if (Byte.MIN_VALUE <= ival && ival <= Byte.MAX_VALUE)
-                        code.emitop1(bipush, ival);
-                    else if (Short.MIN_VALUE <= ival && ival <= Short.MAX_VALUE)
-                        code.emitop2(sipush, ival);
-                    else
-                        ldc();
-                    break;
-                case LONGcode:
-                    long lval = ((Number)value).longValue();
-                    if (lval == 0 || lval == 1)
-                        code.emitop0(lconst_0 + (int)lval);
-                    else
-                        ldc();
-                    break;
-                case FLOATcode:
-                    float fval = ((Number)value).floatValue();
-                    if (isPosZero(fval) || fval == 1.0 || fval == 2.0)
-                        code.emitop0(fconst_0 + (int)fval);
-                    else {
-                        ldc();
-                    }
-                    break;
-                case DOUBLEcode:
-                    double dval = ((Number)value).doubleValue();
-                    if (isPosZero(dval) || dval == 1.0)
-                        code.emitop0(dconst_0 + (int)dval);
-                    else
-                        ldc();
-                    break;
-                case OBJECTcode:
-                    ldc();
-                    break;
-                default:
-                    Assert.error();
-                }
+                break;
+            default:
+                Assert.error();
             }
             return stackItem[typecode];
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Sep 29 14:38:51 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,6 @@
 
 import java.util.*;
 
-import com.sun.tools.javac.code.Type.MethodType;
-import com.sun.tools.javac.comp.ConstablesVisitor.SpecialConstantsHelper.SpecialConstant;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
 
@@ -130,8 +128,6 @@
     Object makePoolValue(Object o) {
         if (o instanceof DynamicMethodSymbol) {
             return new DynamicMethod((DynamicMethodSymbol)o, types);
-        } else if (o instanceof DynamicFieldSymbol) {
-            return new Pool.ConstantDynamic((DynamicFieldSymbol)o, types);
         } else if (o instanceof MethodSymbol) {
             return new Method((MethodSymbol)o, types);
         } else if (o instanceof VarSymbol) {
@@ -158,11 +154,6 @@
         return n == null ? -1 : n.intValue();
     }
 
-    boolean varSymNeedsInitializer(VarSymbol varSym) {
-        Object cvalue = varSym.getConstValue();
-        return (cvalue instanceof SpecialConstant) || cvalue == null;
-    }
-
     static class Method extends DelegatedSymbol<MethodSymbol> {
         UniqueType uniqueType;
         Method(MethodSymbol m, Types types) {
@@ -191,12 +182,10 @@
 
     static class DynamicMethod extends Method {
         public Object[] uniqueStaticArgs;
-        Method internalBSM;
 
         DynamicMethod(DynamicMethodSymbol m, Types types) {
             super(m, types);
             uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types);
-            internalBSM = new Method(m.bsm, types);
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
@@ -209,7 +198,7 @@
             if (!(any instanceof DynamicMethod)) return false;
             DynamicMethodSymbol dm1 = (DynamicMethodSymbol)other;
             DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)any).other;
-            return internalBSM.equals(((DynamicMethod)any).internalBSM) &&
+            return dm1.bsm == dm2.bsm &&
                         dm1.bsmKind == dm2.bsmKind &&
                         Arrays.equals(uniqueStaticArgs,
                             ((DynamicMethod)any).uniqueStaticArgs);
@@ -224,7 +213,7 @@
             int hash = includeDynamicArgs ? super.hashCode() : 0;
             DynamicMethodSymbol dm = (DynamicMethodSymbol)other;
             hash += dm.bsmKind * 7 +
-                    internalBSM.hashCode() * 11;
+                    dm.bsm.hashCode() * 11;
             for (int i = 0; i < dm.staticArgs.length; i++) {
                 hash += (uniqueStaticArgs[i].hashCode() * 23);
             }
@@ -300,66 +289,13 @@
         }
     }
 
-    /**
-     * Pool entry associated with dynamic constants.
-     */
-    public static class ConstantDynamic {
-        MethodHandle bsm;
-        Name name;
-        Type type;
-
-        Object[] args;
-        Types types;
-
-        public ConstantDynamic(Name name, MethodHandle bsm, Object[] args, Types types) {
-            Assert.checkNonNull(args);
-            this.bsm = bsm;
-            MethodSymbol ms = (MethodSymbol)bsm.refSym;
-            MethodType mt = (MethodType)ms.type;
-            this.name = name;
-            this.type = mt.restype;
-            this.args = args;
-            this.types = types;
-        }
-
-        public ConstantDynamic(DynamicFieldSymbol dynField, Types types) {
-            this.bsm = new MethodHandle(dynField.bsmKind, dynField.bsm, types);
-            this.name = dynField.name;
-            this.type = dynField.type;
-            this.args = dynField.staticArgs;
-            this.types = types;
-        }
-
-        @Override
-        public int hashCode() {
-            return bsm.hashCode() * 67 + name.hashCode() + type.hashCode() * 13;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (obj instanceof ConstantDynamic) {
-                ConstantDynamic that = (ConstantDynamic)obj;
-                return that.bsm.equals(bsm) &&
-                        types.isSameType(that.type, type) &&
-                        that.name.equals(name) &&
-                        that.args.equals(args);
-            } else {
-                return false;
-            }
-        }
-
-        public void updateType(Type type) {
-            this.type = type;
-        }
-    }
-
     public static class MethodHandle {
 
         /** Reference kind - see ClassFile */
-        public int refKind;
+        int refKind;
 
         /** Reference symbol */
-        public Symbol refSym;
+        Symbol refSym;
 
         UniqueType uniqueType;
 
@@ -423,15 +359,10 @@
                     expectedKind = MTH;
                     break;
             }
-            Assert.check(!refSym.isStatic() || staticOk, "incorrect static-ness for symbol " + refSym);
-            Assert.check(refSym.kind == expectedKind, "unexpected kind for symbol " + refSym +". \n"
-                    + "Expected = " + expectedKind + "\n"
-                    + "Found = " + refSym.kind);
-            Assert.check(nameFilter.accepts(refSym.name), "incorrect name for symbol " + refSym);
-            Assert.check(!refSym.owner.isInterface() || interfaceOwner,
-                    interfaceOwner ?
-                            "interface owner expected for symbol ":
-                            "non interface owner expected for symbol " + refSym);
+            Assert.check(!refSym.isStatic() || staticOk);
+            Assert.check(refSym.kind == expectedKind);
+            Assert.check(nameFilter.accepts(refSym.name));
+            Assert.check(!refSym.owner.isInterface() || interfaceOwner);
         }
         //where
                 Filter<Name> nonInitFilter = n -> (n != n.table.names.init && n != n.table.names.clinit);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/StringConcat.java	Fri Sep 29 14:38:51 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -360,7 +360,7 @@
             try {
                 make.at(pos);
 
-                List<Type> bsm_staticArgs = List.of(syms.methodHandlesLookupType,
+                List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                         syms.stringType,
                         syms.methodTypeType);
 
@@ -471,7 +471,7 @@
                     constTypes.add(syms.stringType);
                 }
 
-                List<Type> bsm_staticArgs = List.of(syms.methodHandlesLookupType,
+                List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                         syms.stringType,
                         syms.methodTypeType)
                         .append(syms.stringType)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Sep 29 14:38:51 2017 -0700
@@ -298,10 +298,6 @@
      */
     protected Flow flow;
 
-    /** The constables analyzer.
-     */
-    protected ConstablesVisitor constablesVisitor;
-
     /** The modules visitor
      */
     protected Modules modules;
@@ -411,7 +407,6 @@
         chk = Check.instance(context);
         gen = Gen.instance(context);
         flow = Flow.instance(context);
-        constablesVisitor = ConstablesVisitor.instance(context);
         transTypes = TransTypes.instance(context);
         lower = Lower.instance(context);
         annotate = Annotate.instance(context);
@@ -1402,8 +1397,6 @@
 
                 analyzer.flush(env);
 
-                constablesVisitor.analyzeTree(env.tree, env);
-
                 results.add(env);
             }
             finally {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Sep 29 14:38:51 2017 -0700
@@ -3175,34 +3175,3 @@
 # 0: string, 1: string
 compiler.err.illegal.argument.for.option=\
     illegal argument for {0}: {1}
-
-###
-# constant folding errors
-
-# 0: type
-compiler.err.method.handle.not.suitable.indy=\
-    the method handle provided, with type: {0}\n\
-    cannot specify a bootstrap method
-
-compiler.err.initializer.must.be.constant=\
-    initializer must be constant
-
-compiler.err.intrinsics.ldc.must.have.constant.arg=\
-    argument to ldc() must be a constant
-
-compiler.err.intrinsics.indy.must.have.constant.arg=\
-    argument to invokedynamic() must be a constant
-
-compiler.err.invocation.name.cannot.be.empty=\
-    invocation name cannot be an empty string
-
-compiler.err.wrong.number.of.dynamic.args.indy=\
-    wrong number of dynamic arguments for invokedynamic()
-
-compiler.err.type.mismatch.dynamic.arg=\
-    type mismatch between dynamic argument and provided method type at invokedynamic()
-
-# 0: string, 1: string
-compiler.err.reflective.error=\
-    error in reflective call\n\
-    while trying to invoke method \"{0}\" of class \"{1}\"
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri Sep 29 14:38:51 2017 -0700
@@ -38,7 +38,6 @@
 import com.sun.tools.javac.code.Directive.RequiresDirective;
 import com.sun.tools.javac.code.Scope.*;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.comp.Resolve;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -1620,7 +1619,6 @@
         public JCExpression meth;
         public List<JCExpression> args;
         public Type varargsElement;
-        public Resolve.MethodResolutionPhase resolutionPhase;
         protected JCMethodInvocation(List<JCExpression> typeargs,
                         JCExpression meth,
                         List<JCExpression> args)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Fri Sep 29 14:38:51 2017 -0700
@@ -858,14 +858,6 @@
             return symbol(((JCAnnotatedType) tree).underlyingType);
         case REFERENCE:
             return ((JCMemberReference) tree).sym;
-        case VARDEF :
-            return ((JCVariableDecl)tree).sym;
-        case TYPEIDENT:
-            return ((JCPrimitiveTypeTree)tree).type.tsym;
-        case TYPEARRAY:
-            return ((JCArrayTypeTree)tree).type.tsym;
-        case APPLY:
-            return symbol(((JCMethodInvocation)tree).meth);
         default:
             return null;
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Sep 28 22:16:02 2017 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Fri Sep 29 14:38:51 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -185,21 +185,6 @@
     public final Name RUNTIME;
     public final Name SOURCE;
 
-    // members of java.lang.invoke.Constables
-    public final Name methodType;
-    public final Name virtualMethodHandle;
-    public final Name staticMethodHandle;
-    public final Name getterMethodHandle;
-    public final Name staticGetterMethodHandle;
-    public final Name setterMethodHandle;
-    public final Name staticSetterMethodHandle;
-    public final Name constructorMethodHandle;
-    public final Name specialMethodHandle;
-    public final Name indyDescriptor;
-    public final Name invokedynamic;
-    public final Name of;
-    public final Name ldc;
-
     // other identifiers
     public final Name T;
     public final Name deprecated;
@@ -363,21 +348,6 @@
         RUNTIME = fromString("RUNTIME");
         SOURCE = fromString("SOURCE");
 
-        // members of java.lang.invoke.Constables
-        methodType = fromString("methodType");
-        virtualMethodHandle = fromString("virtualMethodHandle");
-        staticMethodHandle = fromString("staticMethodHandle");
-        getterMethodHandle = fromString("getterMethodHandle");
-        staticGetterMethodHandle = fromString("staticGetterMethodHandle");
-        setterMethodHandle = fromString("setterMethodHandle");
-        staticSetterMethodHandle = fromString("staticSetterMethodHandle");
-        constructorMethodHandle = fromString("constructorMethodHandle");
-        specialMethodHandle = fromString("specialMethodHandle");
-        indyDescriptor = fromString("indyDescriptor");
-        invokedynamic = fromString("invokedynamic");
-        of = fromString("of");
-        ldc = fromString("ldc");
-
         // other identifiers
         T = fromString("T");
         deprecated = fromString("deprecated");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/SpecialConstantUtils.java	Thu Sep 28 22:16:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,403 +0,0 @@
-/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.util;
-
-import java.lang.reflect.Field;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.charset.Charset;
-
-import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Symbol.ModuleSymbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.Type.ArrayType;
-import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.code.Type.MethodType;
-import com.sun.tools.javac.code.Types;
-import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.comp.Resolve;
-import com.sun.tools.javac.jvm.ClassFile;
-import com.sun.tools.javac.jvm.Pool;
-import com.sun.tools.javac.resources.CompilerProperties.Errors;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.TreeInfo;
-
-import static com.sun.tools.javac.code.Flags.STATIC;
-import static com.sun.tools.javac.code.TypeTag.ARRAY;
-import static com.sun.tools.javac.tree.JCTree.Tag.APPLY;
-
-/** This class is a support tool to parse a method descriptor and obtain a list of the types
- *  represented in it.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- */
-public class SpecialConstantUtils {
-
-    public SpecialConstantUtils(Context context) {
-        types = Types.instance(context);
-        names = Names.instance(context);
-        syms = Symtab.instance(context);
-        rs = Resolve.instance(context);
-        log = Log.instance(context);
-        try {
-            methodHandleRefClass = Class.forName("java.lang.invoke.MethodHandleRef", false, null);
-            methodTypeRefClass = Class.forName("java.lang.invoke.MethodTypeRef", false, null);
-            classRefClass = Class.forName("java.lang.invoke.ClassRef", false, null);
-            constantRefClass = Class.forName("java.lang.invoke.ConstantRef", false, null);
-            constablesClass = Class.forName("java.lang.invoke.Constables", false, null);
-            bootstrapSpecifierClass = Class.forName("java.lang.invoke.BootstrapSpecifier", false, null);
-            dynamicConstantClass = Class.forName("java.lang.invoke.DynamicConstantRef", false, null);
-        } catch (ClassNotFoundException ex) {
-            methodHandleRefClass = null;
-            methodTypeRefClass = null;
-            constantRefClass = null;
-            classRefClass = null;
-            bootstrapSpecifierClass = null;
-            dynamicConstantClass = null;
-            constablesClass = null;
-        }
-    }
-
-    final Types types;
-    final Names names;
-    final Symtab syms;
-    final Resolve rs;
-    final Log log;
-    ModuleSymbol currentModule;
-
-    /** The unread portion of the currently read type is
-     *  signature[sigp..siglimit-1].
-     */
-    byte[] signature;
-    int sigp;
-    int siglimit;
-    boolean sigEnterPhase = false;
-    byte[] signatureBuffer;
-    int sbp;
-
-    /** Convert signature to type, where signature is a byte array segment.
-     */
-    public Type descriptorToType(String descriptor, ModuleSymbol currentModule, boolean methodDescriptor) {
-        byte[] sig = descriptor.getBytes(Charset.forName("UTF-8"));
-        signature = sig;
-        sigp = 0;
-        siglimit = sig.length - 1;
-        sbp = 0;
-        signatureBuffer = new byte[sig.length];
-        this.currentModule = currentModule;
-        try {
-            if (methodDescriptor) {
-                return internalMethodDescriptorToType();
-            } else { // type descriptor
-                return sigToType();
-            }
-        } catch (AssertionError ae) {
-            return Type.noType;
-        }
-    }
-
-    private Type internalMethodDescriptorToType() {
-        if (signature[sigp] != '(') {
-            throw new AssertionError("bad descriptor");
-        }
-        sigp++;
-        List<Type> argtypes = sigToTypes(')');
-        Type restype = sigToType();
-        return new MethodType(argtypes,
-                              restype,
-                              List.nil(),
-                              syms.methodClass);
-    }
-
-    /** Convert signature to type, where signature is implicit.
-     */
-    Type sigToType() {
-        switch ((char) signature[sigp]) {
-        case 'B':
-            sigp++;
-            return syms.byteType;
-        case 'C':
-            sigp++;
-            return syms.charType;
-        case 'D':
-            sigp++;
-            return syms.doubleType;
-        case 'F':
-            sigp++;
-            return syms.floatType;
-        case 'I':
-            sigp++;
-            return syms.intType;
-        case 'J':
-            sigp++;
-            return syms.longType;
-        case 'L':
-            {
-                Type t = classSigToType();
-                if (sigp < siglimit && signature[sigp] == '.') {
-                    throw new AssertionError("deprecated inner class signature syntax");
-                }
-                return t;
-            }
-        case 'S':
-            sigp++;
-            return syms.shortType;
-        case 'V':
-            sigp++;
-            return syms.voidType;
-        case 'Z':
-            sigp++;
-            return syms.booleanType;
-        case '[':
-            sigp++;
-            return new ArrayType(sigToType(), syms.arrayClass);
-        default:
-            throw new AssertionError("bad descriptor");
-        }
-    }
-
-    /** Convert class signature to type, where signature is implicit.
-     */
-    Type classSigToType() {
-        if (signature[sigp] != 'L') {
-            throw new AssertionError("bad descriptor");
-        }
-        sigp++;
-        Type outer = Type.noType;
-        int startSbp = sbp;
-
-        while (true) {
-            final byte c = signature[sigp++];
-            switch (c) {
-
-            case ';': {         // end
-                ClassSymbol t = enterClass(names.fromUtf(signatureBuffer,
-                                                         startSbp,
-                                                         sbp - startSbp));
-
-                try {
-                    return (outer == Type.noType) ?
-                            t.erasure(types) :
-                        new ClassType(outer, List.<Type>nil(), t);
-                } finally {
-                    sbp = startSbp;
-                }
-            }
-            case '.':
-                //we have seen an enclosing non-generic class
-                if (outer != Type.noType) {
-                    ClassSymbol t = enterClass(names.fromUtf(signatureBuffer,
-                                                 startSbp,
-                                                 sbp - startSbp));
-                    outer = new ClassType(outer, List.<Type>nil(), t);
-                }
-                signatureBuffer[sbp++] = (byte)'$';
-                continue;
-            case '/':
-                signatureBuffer[sbp++] = (byte)'.';
-                continue;
-            default:
-                signatureBuffer[sbp++] = c;
-                continue;
-            }
-        }
-    }
-
-    ClassSymbol enterClass(Name name) {
-        return syms.enterClass(currentModule, name);
-    }
-
-    /** Convert (implicit) signature to list of types
-     *  until `terminator' is encountered.
-     */
-    List<Type> sigToTypes(char terminator) {
-        List<Type> head = List.of(null);
-        List<Type> tail = head;
-        while (signature[sigp] != terminator)
-            tail = tail.setTail(List.of(sigToType()));
-        sigp++;
-        return head.tail;
-    }
-
-    public Object convertConstant(JCTree tree, Env<AttrContext> attrEnv, Object constant, ModuleSymbol currentModule) {
-        return convertConstant(tree, attrEnv, constant, currentModule, false);
-    }
-
-    public Object convertConstant(JCTree tree, Env<AttrContext> attrEnv, Object constant, ModuleSymbol currentModule, boolean bsmArg) {
-        if (methodHandleRefClass.isInstance(constant)) {
-            String name = (String)invokeReflectiveMethod(methodHandleRefClass, constant, "name");
-            int refKind = (int)invokeReflectiveMethod(methodHandleRefClass, constant, "refKind");
-            Object owner = invokeReflectiveMethod(methodHandleRefClass, constant, "owner");
-            String ownerDescriptor = (String)invokeReflectiveMethod(classRefClass, owner, "descriptorString");
-            Type ownerType = descriptorToType(ownerDescriptor, currentModule, false);
-            Object mtConstant = invokeReflectiveMethod(methodHandleRefClass, constant, "type");
-            String methodTypeDesc = (String)invokeReflectiveMethod(methodTypeRefClass, mtConstant, "descriptorString");
-            MethodType mType = (MethodType)descriptorToType(
-                    methodTypeDesc, currentModule, true);
-            Symbol refSymbol = getReferenceSymbol(refKind, ownerType.tsym, name, mType);
-            return new Pool.MethodHandle(refKind, refSymbol, types);
-        } else if (methodTypeRefClass.isInstance(constant)) {
-            String descriptor = (String)invokeReflectiveMethod(methodTypeRefClass, constant, "descriptorString");
-            return types.erasure(descriptorToType(descriptor, currentModule, true));
-        } else if (classRefClass.isInstance(constant)) {
-            String descriptor = (String)invokeReflectiveMethod(classRefClass, constant, "descriptorString");
-            if ((boolean)invokeReflectiveMethod(classRefClass, constant, "isPrimitive")) {
-                if (bsmArg) {
-                    Object condy = invokeReflectiveMethod(constablesClass, null, "reduce", new Class<?>[]{constantRefClass}, new Object[]{constant});
-                    return convertConstant(tree, attrEnv, condy, currentModule);
-                } else {
-                    return rs.resolveInternalField(tree, attrEnv, types.boxedClass(descriptor).type, names.TYPE);
-                }
-            }
-            Type type = descriptorToType(descriptor, currentModule, false);
-            return type.hasTag(ARRAY) ? type : type.tsym;
-        } else if (dynamicConstantClass.isInstance(constant)) {
-            String name = (String)invokeReflectiveMethod(dynamicConstantClass, constant, "name");
-            Object mh = invokeReflectiveMethod(dynamicConstantClass, constant, "bootstrapMethod");
-            Pool.MethodHandle methodHandle = (Pool.MethodHandle)convertConstant(tree, attrEnv, mh, currentModule);
-            Object[] args = (Object[])invokeReflectiveMethod(dynamicConstantClass, constant, "bootstrapArgs");
-            Object[] convertedArgs = convertConstants(tree, attrEnv, args, currentModule, true);
-            return new Pool.ConstantDynamic(names.fromString(name), methodHandle, convertedArgs, types);
-        }
-        return constant;
-    }
-
-    public Object[] convertConstants(JCTree tree, Env<AttrContext> attrEnv, Object[] constants, ModuleSymbol currentModule, boolean bsmArgs) {
-        if (constants == null || constants.length == 0) {
-            return constants;
-        }
-        Object[] result = new Object[constants.length];
-        int i = 0;
-        for (Object constant : constants) {
-            result[i] = convertConstant(tree, attrEnv, constant, currentModule, bsmArgs);
-            i++;
-        }
-        return result;
-    }
-
-    public boolean isPrimitiveClassRef(Object constant) {
-        return classRefClass.isInstance(constant) &&
-                (boolean)invokeReflectiveMethod(classRefClass, constant, "isPrimitive");
-    }
-
-    public Class<?> methodHandleRefClass;
-    public Class<?> methodTypeRefClass;
-    public Class<?> classRefClass;
-    public Class<?> constantRefClass;
-    public Class<?> constablesClass;
-    public Class<?> bootstrapSpecifierClass;
-    public Class<?> dynamicConstantClass;
-
-    private Symbol getReferenceSymbol(int refKind, Symbol owner, String name, MethodType methodType) {
-        long flags = refKind == ClassFile.REF_getStatic ||
-                refKind == ClassFile.REF_putStatic ||
-                refKind == ClassFile.REF_invokeStatic ? STATIC : 0;
-        Name symbolName = refKind == ClassFile.REF_newInvokeSpecial ? names.init : names.fromString(name);
-        switch (refKind) {
-            case ClassFile.REF_newInvokeSpecial :
-            case ClassFile.REF_invokeVirtual:
-            case ClassFile.REF_invokeStatic:
-            case ClassFile.REF_invokeSpecial:
-            case ClassFile.REF_invokeInterface:
-                return new MethodSymbol(flags, symbolName, methodType, owner);
-            case ClassFile.REF_putField:
-                return new VarSymbol(flags, symbolName, methodType.argtypes.tail.head, owner);
-            case ClassFile.REF_putStatic:
-                return new VarSymbol(flags, symbolName, methodType.argtypes.head, owner);
-            case ClassFile.REF_getField:
-            case ClassFile.REF_getStatic:
-                return new VarSymbol(flags, symbolName, methodType.restype, owner);
-            default:
-                throw new AssertionError("invalid refKind value " + refKind);
-        }
-    }
-
-    public Object invokeReflectiveMethod(
-            Class<?> hostClass,
-            Object instance,
-            String methodName) {
-        return invokeReflectiveMethod(hostClass, instance, methodName, new Class<?>[0], new Object[0]);
-    }
-
-    public Object invokeReflectiveMethod(
-            Class<?> hostClass,
-            Object instance,
-            String methodName,
-            Class<?>[] argumentTypes,
-            Object[] arguments) {
-        Method theMethod;
-        try {
-            theMethod = hostClass.getDeclaredMethod(methodName, argumentTypes);
-            return theMethod.invoke(instance, arguments);
-        } catch (NoSuchMethodException |
-                SecurityException |
-                IllegalAccessException |
-                IllegalArgumentException |
-                InvocationTargetException ex) {
-            log.error(Errors.ReflectiveError(methodName, hostClass.getCanonicalName()));
-        }
-        return null;
-    }
-
-    public boolean isIntrinsicsIndy(JCTree tree) {
-        return isIntrinsicsIndy(TreeInfo.symbol(tree));
-    }
-
-    public boolean isIntrinsicsIndy(Symbol msym) {
-        return (msym != null &&
-                msym.owner != null &&
-                msym.owner.type != null &&
-                msym.owner.type.tsym == syms.intrinsicsType.tsym &&
-                msym.name == names.invokedynamic);
-    }
-
-    public boolean isIntrinsicsLDCInvocation(Symbol msym) {
-        return (msym != null &&
-                msym.owner != null &&
-                msym.owner.type != null &&
-                msym.owner.type.tsym == syms.intrinsicsType.tsym &&
-                msym.name == names.ldc);
-    }
-
-    public boolean isIntrinsicsLDCInvocation(JCTree tree) {
-        Symbol msym = TreeInfo.symbol(tree);
-        return (tree.hasTag(APPLY) &&
-                msym != null &&
-                msym.owner != null &&
-                msym.owner.type != null &&
-                msym.owner.type.tsym == syms.intrinsicsType.tsym &&
-                msym.name == names.ldc);
-    }
-}