changeset 48764:8d76e47a91e7 exp

Scanner, parser, semantic analysis and attribution support for value types
author sadayapalam
date Tue, 30 Jan 2018 14:45:14 +0530
parents a6c73ed70e90
children c4f88c1fb99b
files src/java.compiler/share/classes/javax/lang/model/element/Modifier.java src/jdk.compiler/share/classes/com/sun/source/tree/NewClassTree.java 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/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/Flow.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.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/util/Names.java src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java test/langtools/tools/javac/diags/examples.not-yet.txt test/langtools/tools/javac/diags/examples/ValuesNotSupported.java test/langtools/tools/javac/valhalla/lworld-values/CheckClone.java test/langtools/tools/javac/valhalla/lworld-values/CheckClone.out test/langtools/tools/javac/valhalla/lworld-values/CheckCyclicMembership.java test/langtools/tools/javac/valhalla/lworld-values/CheckCyclicMembership.out test/langtools/tools/javac/valhalla/lworld-values/CheckEquals.java test/langtools/tools/javac/valhalla/lworld-values/CheckEquals.out test/langtools/tools/javac/valhalla/lworld-values/CheckExtends.java test/langtools/tools/javac/valhalla/lworld-values/CheckExtends.out test/langtools/tools/javac/valhalla/lworld-values/CheckFinal.java test/langtools/tools/javac/valhalla/lworld-values/CheckFinal.out test/langtools/tools/javac/valhalla/lworld-values/CheckFinalize.java test/langtools/tools/javac/valhalla/lworld-values/CheckFinalize.out test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash.java test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash.out test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash01.java test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash01.out test/langtools/tools/javac/valhalla/lworld-values/CheckMakeDefault.java test/langtools/tools/javac/valhalla/lworld-values/CheckMakeDefault.out test/langtools/tools/javac/valhalla/lworld-values/CheckNullAssign.java test/langtools/tools/javac/valhalla/lworld-values/CheckNullAssign.out test/langtools/tools/javac/valhalla/lworld-values/CheckNullCastable.java test/langtools/tools/javac/valhalla/lworld-values/CheckNullCastable.out test/langtools/tools/javac/valhalla/lworld-values/CheckStaticValueFactory.java test/langtools/tools/javac/valhalla/lworld-values/CheckStaticValueFactory.out test/langtools/tools/javac/valhalla/lworld-values/CheckSuperCompileOnly.java test/langtools/tools/javac/valhalla/lworld-values/CheckSync.java test/langtools/tools/javac/valhalla/lworld-values/CheckSync.out test/langtools/tools/javac/valhalla/lworld-values/CheckSynchronized.java test/langtools/tools/javac/valhalla/lworld-values/CheckSynchronized.out test/langtools/tools/javac/valhalla/lworld-values/CheckValueFactoryWithReference.java test/langtools/tools/javac/valhalla/lworld-values/CheckValueFactoryWithReference.out test/langtools/tools/javac/valhalla/lworld-values/CheckValueModifier.java test/langtools/tools/javac/valhalla/lworld-values/CheckValueModifier.out test/langtools/tools/javac/valhalla/lworld-values/Point.java
diffstat 53 files changed, 907 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java	Tue Jan 30 14:45:14 2018 +0530
@@ -58,6 +58,14 @@
      * @since 1.8
      */
      DEFAULT,
+    /**
+     * The modifier {@code __ByValue}
+     */
+    VALUE,
+    /**
+     * The modifier {@code __ValueFactory}
+     */
+    STATICVALUEFACTORY,
     /** The modifier {@code static} */          STATIC,
     /** The modifier {@code final} */           FINAL,
     /** The modifier {@code transient} */       TRANSIENT,
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/NewClassTree.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/NewClassTree.java	Tue Jan 30 14:45:14 2018 +0530
@@ -49,6 +49,18 @@
  * @since 1.6
  */
 public interface NewClassTree extends ExpressionTree {
+
+    /**
+     * There are two kinds of new class trees: (i) references (new String("Foo"))
+     * (ii) default values (__MakeDefault Point())
+     */
+    public enum CreationMode {
+        /** enum constant for reference creation. */
+        NEW,
+        /** enum constant for default value creation. */
+        DEFAULT_VALUE,
+    }
+
     /**
      * Returns the enclosing expression, or {@code null} if none.
      * @return the enclosing expression
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Tue Jan 30 14:45:14 2018 +0530
@@ -98,6 +98,9 @@
     /** Added in SE8, represents constructs implicitly declared in source. */
     public static final int MANDATED     = 1<<15;
 
+    /** Marks a type as a value-type */
+    public static final int VALUE        = 1<<16;
+
     public static final int StandardFlags = 0x0fff;
 
     // Because the following access flags are overloaded with other
@@ -107,6 +110,7 @@
     public static final int ACC_SUPER    = 0x0020;
     public static final int ACC_BRIDGE   = 0x0040;
     public static final int ACC_VARARGS  = 0x0080;
+    public static final int ACC_VALUE    = 0x0100;
     public static final int ACC_MODULE   = 0x8000;
 
     /*****************************************
@@ -122,6 +126,11 @@
      */
     public static final int HASINIT          = 1<<18;
 
+    /** Flag is set for a method symbol that acts as a static factory method for a value type
+     *  (contrast with vminit methods flagged as STATICVALUEFACTORY)
+     */
+    public static final int STATICVALUEFACTORY = 1<<19;
+
     /** Flag is set for compiler-generated anonymous method symbols
      *  that `own' an initializer block.
      */
@@ -317,7 +326,7 @@
      */
     public static final int
         AccessFlags           = PUBLIC | PROTECTED | PRIVATE,
-        LocalClassFlags       = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
+        LocalClassFlags       = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC | VALUE,
         MemberClassFlags      = LocalClassFlags | INTERFACE | AccessFlags,
         ClassFlags            = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
         InterfaceVarFlags     = FINAL | STATIC | PUBLIC,
@@ -326,9 +335,9 @@
         ConstructorFlags      = AccessFlags,
         InterfaceMethodFlags  = ABSTRACT | PUBLIC,
         MethodFlags           = AccessFlags | ABSTRACT | STATIC | NATIVE |
-                                SYNCHRONIZED | FINAL | STRICTFP;
+                                SYNCHRONIZED | FINAL | STRICTFP | STATICVALUEFACTORY;
     public static final long
-        ExtendedStandardFlags       = (long)StandardFlags | DEFAULT,
+        ExtendedStandardFlags       = (long)StandardFlags | DEFAULT | VALUE | STATICVALUEFACTORY,
         ModifierFlags               = ((long)StandardFlags & ~INTERFACE) | DEFAULT,
         InterfaceMethodMask         = ABSTRACT | PRIVATE | STATIC | PUBLIC | STRICTFP | DEFAULT,
         AnnotationTypeElementMask   = ABSTRACT | PUBLIC,
@@ -353,6 +362,8 @@
             if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
             if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
             if (0 != (flags & DEFAULT))   modifiers.add(Modifier.DEFAULT);
+            if (0 != (flags & VALUE))     modifiers.add(Modifier.VALUE);
+            if (0 != (flags & STATICVALUEFACTORY))     modifiers.add(Modifier.STATICVALUEFACTORY);
             modifiers = Collections.unmodifiableSet(modifiers);
             modifierSets.put(flags, modifiers);
         }
@@ -394,9 +405,11 @@
         ANNOTATION(Flags.ANNOTATION),
         DEPRECATED(Flags.DEPRECATED),
         HASINIT(Flags.HASINIT),
+        STATICVALUEFACTORY(Flags.STATICVALUEFACTORY),
         BLOCK(Flags.BLOCK),
         ENUM(Flags.ENUM),
         MANDATED(Flags.MANDATED),
+        VALUE(Flags.VALUE),
         NOOUTERTHIS(Flags.NOOUTERTHIS),
         EXISTS(Flags.EXISTS),
         COMPOUND(Flags.COMPOUND),
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Tue Jan 30 14:45:14 2018 +0530
@@ -181,7 +181,8 @@
         DIAMOND_WITH_ANONYMOUS_CLASS_CREATION(JDK9, Fragments.FeatureDiamondAndAnonClass, DiagKind.NORMAL),
         UNDERSCORE_IDENTIFIER(MIN, JDK8),
         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
-        LOCAL_VARIABLE_TYPE_INFERENCE(JDK10);
+        LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
+        VALUE_TYPES(JDK11, Fragments.FeatureValueTypes, DiagKind.NORMAL);
 
         enum DiagKind {
             NORMAL,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Tue Jan 30 14:45:14 2018 +0530
@@ -983,6 +983,10 @@
        }
     }
 
+    public boolean isValue(Type t) {
+        return t.tsym != null && (t.tsym.flags_field & Flags.VALUE) != 0;
+    }
+
     // <editor-fold defaultstate="collapsed" desc="isSubtype">
     /**
      * Is t an unchecked subtype of s?
@@ -1103,7 +1107,7 @@
                      return isSubtypeNoCapture(t.getUpperBound(), s);
                  case BOT:
                      return
-                         s.hasTag(BOT) || s.hasTag(CLASS) ||
+                         s.hasTag(BOT) || (s.hasTag(CLASS) && !isValue(s)) ||
                          s.hasTag(ARRAY) || s.hasTag(TYPEVAR);
                  case WILDCARD: //we shouldn't be here - avoids crash (see 7034495)
                  case NONE:
@@ -1744,7 +1748,7 @@
 
             @Override
             public Boolean visitClassType(ClassType t, Type s) {
-                if (s.hasTag(ERROR) || s.hasTag(BOT))
+                if (s.hasTag(ERROR) || s.hasTag(BOT) && !isValue(t))
                     return true;
 
                 if (s.hasTag(TYPEVAR)) {
@@ -5111,6 +5115,11 @@
                     break;
                 case CLASS:
                     append('L');
+                    // TODO(Srikanth): Fix commented if statement below.
+//                    if (types.isValue(type))
+//                        append('Q');
+//                    else
+//                        append('L');
                     assembleClassSig(type);
                     append(';');
                     break;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Jan 30 14:45:14 2018 +0530
@@ -33,6 +33,7 @@
 import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.NewClassTree.CreationMode;
 import com.sun.source.tree.TreeVisitor;
 import com.sun.source.util.SimpleTreeVisitor;
 import com.sun.tools.javac.code.*;
@@ -294,7 +295,19 @@
             if (v.isResourceVariable()) { //TWR resource
                 log.error(pos, Errors.TryResourceMayNotBeAssigned(v));
             } else {
-                log.error(pos, Errors.CantAssignValToFinalVar(v));
+                boolean complain = true;
+                /* Allow updates to blank final fields inside value factories.
+                   This really results in copy on write and not mutation of the
+                   final field
+                */
+                if (v.getKind() == ElementKind.FIELD && (v.flags() & HASINIT) == 0) {
+                    if (env.enclMethod != null && (env.enclMethod.mods.flags & STATICVALUEFACTORY) != 0) {
+                        if (v.owner == env.enclMethod.sym.owner)
+                            complain = false;
+                    }
+                }
+                if (complain)
+                    log.error(pos, Errors.CantAssignValToFinalVar(v));
             }
         }
     }
@@ -1139,6 +1152,9 @@
                 annotate.queueScanTreeAndTypeAnnotate(tree.init, env, tree.sym, tree.pos());
                 annotate.flush();
             }
+            if (types.isValue(tree.sym.owner.type) && (tree.mods.flags & (Flags.FINAL | Flags.STATIC)) == 0) {
+                log.error(tree.pos(), "value.field.must.be.final");
+            }
         }
 
         VarSymbol v = tree.sym;
@@ -2016,6 +2032,39 @@
 
             chk.checkRefTypes(tree.typeargs, typeargtypes);
 
+            // FIXME(Srikanth): Above checkRefTypes call is missing in mvt branch ??
+            // identity hash code is uncomputable for value instances.
+            final Symbol symbol = TreeInfo.symbol(tree.meth);
+            if (symbol != null && symbol.name == names.identityHashCode && symbol.owner.flatName() == names.java_lang_System) {
+                if (tree.args.length() == 1 && types.isValue(tree.args.head.type))
+                    log.error(tree.pos(), "value.does.not.support", "identityHashCode");
+            }
+
+            /* Is this an ill conceived attempt to invoke jlO methods not available on value types ??
+            */
+            if (types.isValue(qualifier)) {
+                int argSize = argtypes.size();
+                Name name = symbol.name;
+                switch (name.toString()) {
+                    case "wait":
+                        if (argSize == 0
+                                || (types.isConvertible(argtypes.head, syms.longType) &&
+                                (argSize == 1 || (argSize == 2 && types.isConvertible(argtypes.tail.head, syms.intType))))) {
+                            log.error(tree.pos(),"value.does.not.support", name);
+                        }
+                        break;
+                    case "notify":
+                    case "notifyAll":
+                    case "clone":
+                    case "finalize":
+                        if (argSize == 0)
+                            log.error(tree.pos(),"value.does.not.support", name);
+                        break;
+                }
+            }
+
+
+
             // Check that value of resulting type is admissible in the
             // current context.  Also, capture the return type
             Type capturedRes = resultInfo.checkContext.inferenceContext().cachedCapture(tree, restype, true);
@@ -2200,6 +2249,10 @@
                  ((JCVariableDecl) env.tree).init != tree))
                 log.error(tree.pos(), Errors.EnumCantBeInstantiated);
 
+            if (tree.creationMode == CreationMode.NEW && types.isValue(clazztype)) {
+                log.error(tree.pos(), Errors.GarbledValueReferenceInstantiation);
+            }
+
             boolean isSpeculativeDiamondInferenceRound = TreeInfo.isDiamond(tree) &&
                     resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
             boolean skipNonDiamondPath = false;
@@ -2300,6 +2353,22 @@
                         tree.constructorType = instantiatedContext.asInstType(tree.constructorType);
                     });
         }
+        if (tree.creationMode == CreationMode.DEFAULT_VALUE) {
+            if (tree.constructor != null && tree.constructor.isConstructor()) {
+                final List<Type> parameterTypes = tree.constructorType.getParameterTypes();
+                if (!parameterTypes.isEmpty()) {
+                    log.error(tree.pos, "invalid.arguments.to.make.default");
+                }
+                if (!types.isValue(TreeInfo.symbol(tree.clazz).type)) {
+                    log.error(tree.pos, "make.default.with.nonvalue");
+                } else if (env.enclMethod != null && env.enclMethod.sym.owner != TreeInfo.symbol(tree.clazz)) {
+                    log.error(tree.pos, "make.default.with.wrong.value.type", TreeInfo.symbol(tree.clazz));
+                }
+            }
+            if (env.enclMethod != null && (env.enclMethod.mods.flags & STATICVALUEFACTORY) == 0) {
+                log.error(tree.pos, "make.default.in.nonfactory");
+            }
+        }
         chk.validate(tree.typeargs, localEnv);
     }
 
@@ -3408,6 +3477,9 @@
                 if (!types.isCastable(left, right, new Warner(tree.pos()))) {
                     log.error(tree.pos(), Errors.IncomparableTypes(left, right));
                 }
+                if (types.isValue(left) || types.isValue(right)) {
+                    log.error(tree.pos(), "value.does.not.support", tree.operator.name.toString());
+                }
             }
 
             chk.checkDivZero(tree.rhs.pos(), operator, right);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Jan 30 14:45:14 2018 +0530
@@ -730,7 +730,7 @@
      *  @param t             The type to be checked.
      */
     Type checkRefType(DiagnosticPosition pos, Type t) {
-        if (t.isReference())
+        if (t.isReference() && !types.isValue(t))
             return t;
         else
             return typeTagError(pos,
@@ -1162,7 +1162,9 @@
                     mask = implicit = InterfaceMethodFlags;
                 }
             } else {
-                mask = MethodFlags;
+                // instance methods of value types do not have a monitor associated with their `this'
+                mask = ((sym.owner.flags_field & VALUE) != 0 && (flags & Flags.STATIC) == 0) ?
+                        MethodFlags & ~SYNCHRONIZED : MethodFlags;
             }
             // Imply STRICTFP if owner has STRICTFP set.
             if (((flags|implicit) & Flags.ABSTRACT) == 0 ||
@@ -1191,8 +1193,8 @@
             if ((flags & INTERFACE) != 0) implicit |= ABSTRACT;
 
             if ((flags & ENUM) != 0) {
-                // enums can't be declared abstract or final
-                mask &= ~(ABSTRACT | FINAL);
+                // enums can't be declared abstract or final or value type
+                mask &= ~(ABSTRACT | FINAL | VALUE);
                 implicit |= implicitEnumFinalFlag(tree);
             }
             // Imply STRICTFP if owner has STRICTFP set.
@@ -1225,7 +1227,7 @@
                  &&
                  checkDisjoint(pos, flags,
                                ABSTRACT | INTERFACE,
-                               FINAL | NATIVE | SYNCHRONIZED)
+                               FINAL | NATIVE | SYNCHRONIZED | VALUE)
                  &&
                  checkDisjoint(pos, flags,
                                PUBLIC,
@@ -2163,6 +2165,45 @@
         }
     }
 
+    // A value class cannot contain a field of its own type either or indirectly.
+    void checkNonCyclicMembership(JCClassDecl tree) {
+        Assert.check((tree.sym.flags_field & LOCKED) == 0);
+        try {
+            tree.sym.flags_field |= LOCKED;
+            for (List<? extends JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                if (l.head.hasTag(VARDEF)) {
+                    JCVariableDecl field = (JCVariableDecl) l.head;
+                    if (!field.sym.isStatic()) {
+                        Type fieldType = field.sym.type;
+                        if (types.isValue(fieldType)) {
+                            checkNonCyclicMembership((ClassSymbol) fieldType.tsym, field.pos());
+                        }
+                    }
+                }
+            }
+        } finally {
+            tree.sym.flags_field &= ~LOCKED;
+        }
+
+    }
+    // where
+    private void checkNonCyclicMembership(ClassSymbol c, DiagnosticPosition pos) {
+        if ((c.flags_field & LOCKED) != 0) {
+            log.error(pos, Errors.CyclicValueTypeMembership(c));
+            return;
+        }
+        try {
+            c.flags_field |= LOCKED;
+            for (Symbol fld : c.members().getSymbols(s -> s.kind == VAR &&
+                    !s.isStatic() &&
+                    (types.isValue(s.type)), NON_RECURSIVE)) {
+                checkNonCyclicMembership((ClassSymbol) fld.type.tsym, pos);
+            }
+        } finally {
+            c.flags_field &= ~LOCKED;
+        }
+    }
+
     void checkNonCyclicDecl(JCClassDecl tree) {
         CycleChecker cc = new CycleChecker();
         cc.scan(tree);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Jan 30 14:45:14 2018 +0530
@@ -41,6 +41,7 @@
 
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
+import javax.lang.model.element.ElementKind;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.BLOCK;
@@ -1539,6 +1540,7 @@
         }
 
         private boolean isInitialConstructor = false;
+        private JCMethodDecl enclMethod = null;
 
         @Override
         protected void markDead() {
@@ -1624,7 +1626,15 @@
                 }
                 inits.incl(sym.adr);
             } else if ((sym.flags() & FINAL) != 0) {
-                log.error(pos, Errors.VarMightAlreadyBeAssigned(sym));
+                boolean complain = true;
+                if (sym.getKind() == ElementKind.FIELD && (sym.flags() & HASINIT) == 0) {
+                    if (enclMethod != null && (enclMethod.mods.flags & STATICVALUEFACTORY) != 0) {
+                        if (sym.owner == enclMethod.sym.owner)
+                            complain = false;
+                    }
+                }
+                if (complain)
+                    log.error(pos, Errors.VarMightAlreadyBeAssigned(sym));
             }
         }
         //where
@@ -1864,8 +1874,10 @@
 
                 Assert.check(pendingExits.isEmpty());
                 boolean lastInitialConstructor = isInitialConstructor;
+                JCMethodDecl lastEnclMethod = enclMethod;
                 try {
                     isInitialConstructor = TreeInfo.isInitialConstructor(tree);
+                    enclMethod = tree;
 
                     if (!isInitialConstructor) {
                         firstadr = nextadr;
@@ -1921,6 +1933,7 @@
                     firstadr = firstadrPrev;
                     returnadr = returnadrPrev;
                     isInitialConstructor = lastInitialConstructor;
+                    enclMethod = lastEnclMethod;
                 }
             } finally {
                 lint = lintPrev;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Jan 30 14:45:14 2018 +0530
@@ -228,6 +228,15 @@
             m.defaultValue = annotate.unfinishedDefaultValue(); // set it to temporary sentinel for now
             annotate.annotateDefaultValueLater(tree.defaultValue, localEnv, m, tree.pos());
         }
+        if ((tree.mods.flags & STATICVALUEFACTORY) != 0) {
+            if ((tree.mods.flags & STATIC) == 0) {
+                log.error(tree.pos(), "value.factory.must.be.static");
+            }
+            final Type returnType = m.getReturnType();
+            if (returnType != null && returnType.tsym != m.owner) {
+                log.error(tree.restype != null ? tree.restype.pos() : tree.pos(), "type.found.req", returnType.tsym, m.owner);
+            }
+        }
     }
 
     /** Create a fresh environment for method bodies.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Tue Jan 30 14:45:14 2018 +0530
@@ -672,8 +672,11 @@
             // Determine supertype.
             Type supertype;
             JCExpression extending;
+            final boolean isValueType = (tree.mods.flags & Flags.VALUE) != 0;
 
             if (tree.extending != null) {
+                if (isValueType)
+                    log.error(tree.pos(), "value.may.not.extend");
                 extending = clearTypeParams(tree.extending);
                 supertype = attr.attribBase(extending, baseEnv, true, false, true);
             } else {
@@ -846,6 +849,9 @@
                 !env.toplevel.sourcefile.isNameCompatible(sym.name.toString(),JavaFileObject.Kind.SOURCE)) {
                 sym.flags_field |= AUXILIARY;
             }
+            if ((tree.mods.flags & Flags.VALUE) != 0 && (tree.mods.flags & Flags.FINAL) == 0) {
+                log.error(tree.pos(), "value.must.be.final");
+            }
         }
     }
 
@@ -943,6 +949,9 @@
                 typeAnnotations.organizeTypeAnnotationsSignatures(env, (JCClassDecl)env.tree);
                 typeAnnotations.validateTypeAnnotationsSignatures(env, (JCClassDecl)env.tree);
             }
+            if (types.isValue(tree.sym.type)) {
+                chk.checkNonCyclicMembership(tree);
+            }
         }
 
         /** Enter members for a class.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Jan 30 14:45:14 2018 +0530
@@ -33,6 +33,8 @@
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.source.tree.ModuleTree.ModuleKind;
 
+import com.sun.source.tree.NewClassTree.CreationMode;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Source.Feature;
 import com.sun.tools.javac.parser.Tokens.*;
@@ -353,6 +355,7 @@
                 case THIS:
                 case SUPER:
                 case NEW:
+                case VDEFAULT:
                     if (stopAtStatement)
                         return;
                     break;
@@ -1154,12 +1157,14 @@
             } else return illegal();
             break;
         case NEW:
+        case VDEFAULT:
             if (typeArgs != null) return illegal();
             if ((mode & EXPR) != 0) {
                 mode = EXPR;
+                CreationMode creationMode = getCreationMode(token);
                 nextToken();
                 if (token.kind == LT) typeArgs = typeArguments(false);
-                t = creator(pos, typeArgs);
+                t = creator(pos, creationMode, typeArgs);
                 typeArgs = null;
             } else return illegal();
             break;
@@ -1278,9 +1283,10 @@
                                 if (typeArgs != null) return illegal();
                                 mode = EXPR;
                                 int pos1 = token.pos;
+                                CreationMode creationMode = getCreationMode(token);
                                 nextToken();
                                 if (token.kind == LT) typeArgs = typeArguments(false);
-                                t = innerCreator(pos1, typeArgs, t);
+                                t = innerCreator(pos1, creationMode, typeArgs, t);
                                 typeArgs = null;
                                 break loop;
                             }
@@ -1372,6 +1378,10 @@
         return term3Rest(t, typeArgs);
     }
 
+    private CreationMode getCreationMode(Token token) {
+        return token.kind == NEW ? CreationMode.NEW : CreationMode.DEFAULT_VALUE;
+    }
+
     JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
         if (typeArgs != null) illegal();
         while (true) {
@@ -1413,13 +1423,14 @@
                     nextToken();
                     t = arguments(typeArgs, t);
                     typeArgs = null;
-                } else if (token.kind == NEW && (mode & EXPR) != 0) {
+                } else if ((token.kind == NEW || token.kind == VDEFAULT) && (mode & EXPR) != 0) {
                     if (typeArgs != null) return illegal();
                     mode = EXPR;
                     int pos2 = token.pos;
+                    CreationMode creationMode = getCreationMode(token);
                     nextToken();
                     if (token.kind == LT) typeArgs = typeArguments(false);
-                    t = innerCreator(pos2, typeArgs, t);
+                    t = innerCreator(pos2, creationMode, typeArgs, t);
                     typeArgs = null;
                 } else {
                     List<JCAnnotation> tyannos = null;
@@ -1573,7 +1584,7 @@
                         case INTLITERAL: case LONGLITERAL: case FLOATLITERAL:
                         case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
                         case TRUE: case FALSE: case NULL:
-                        case NEW: case IDENTIFIER: case ASSERT: case ENUM: case UNDERSCORE:
+                        case NEW: case VDEFAULT: case IDENTIFIER: case ASSERT: case ENUM: case UNDERSCORE:
                         case BYTE: case SHORT: case CHAR: case INT:
                         case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
                             return ParensResult.CAST;
@@ -2001,8 +2012,8 @@
         }
         Name refName;
         ReferenceMode refMode;
-        if (token.kind == NEW) {
-            refMode = ReferenceMode.NEW;
+        if (token.kind == NEW || token.kind == VDEFAULT) {
+            refMode = ReferenceMode.NEW; // TODO(Srikanth): What is the right thing to do here ?
             refName = names.init;
             nextToken();
         } else {
@@ -2014,7 +2025,7 @@
 
     /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
      */
-    JCExpression creator(int newpos, List<JCExpression> typeArgs) {
+    JCExpression creator(int newpos, CreationMode creationMode, List<JCExpression> typeArgs) {
         List<JCAnnotation> newAnnotations = typeAnnotationsOpt();
 
         switch (token.kind) {
@@ -2088,7 +2099,7 @@
             }
             return e;
         } else if (token.kind == LPAREN) {
-            JCNewClass newClass = classCreatorRest(newpos, null, typeArgs, t);
+            JCNewClass newClass = classCreatorRest(newpos, creationMode, null, typeArgs, t);
             if (newClass.def != null) {
                 assert newClass.def.mods.annotations.isEmpty();
                 if (newAnnotations.nonEmpty()) {
@@ -2117,7 +2128,7 @@
 
     /** InnerCreator = [Annotations] Ident [TypeArguments] ClassCreatorRest
      */
-    JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression encl) {
+    JCExpression innerCreator(int newpos, CreationMode creationMode, List<JCExpression> typeArgs, JCExpression encl) {
         List<JCAnnotation> newAnnotations = typeAnnotationsOpt();
 
         JCExpression t = toP(F.at(token.pos).Ident(ident()));
@@ -2131,7 +2142,7 @@
             t = typeArguments(t, true);
             mode = oldmode;
         }
-        return classCreatorRest(newpos, encl, typeArgs, t);
+        return classCreatorRest(newpos, creationMode, encl, typeArgs, t);
     }
 
     /** ArrayCreatorRest = [Annotations] "[" ( "]" BracketsOpt ArrayInitializer
@@ -2211,6 +2222,7 @@
     /** ClassCreatorRest = Arguments [ClassBody]
      */
     JCNewClass classCreatorRest(int newpos,
+                                  CreationMode creationMode,
                                   JCExpression encl,
                                   List<JCExpression> typeArgs,
                                   JCExpression t)
@@ -2223,7 +2235,9 @@
             JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
             body = toP(F.at(pos).AnonymousClassDef(mods, defs));
         }
-        return toP(F.at(newpos).NewClass(encl, typeArgs, t, args, body));
+        JCNewClass newClass = toP(F.at(newpos).NewClass(encl, typeArgs, t, args, body));
+        newClass.creationMode = creationMode;
+        return newClass;
     }
 
     /** ArrayInitializer = "{" [VariableInitializer {"," VariableInitializer}] [","] "}"
@@ -2363,6 +2377,7 @@
         case ASSERT:
             return List.of(parseSimpleStatement());
         case MONKEYS_AT:
+        case VALUE:
         case FINAL: {
             Comment dc = token.comment(CommentStyle.JAVADOC);
             JCModifiers mods = modifiersOpt();
@@ -2799,6 +2814,8 @@
             case STRICTFP    : flag = Flags.STRICTFP; break;
             case MONKEYS_AT  : flag = Flags.ANNOTATION; break;
             case DEFAULT     : checkSourceLevel(Feature.DEFAULT_METHODS); flag = Flags.DEFAULT; break;
+            case VALUE       : checkSourceLevel(Feature.VALUE_TYPES); flag = Flags.VALUE; break;
+            case STATICVALUEFACTORY: flag = Flags.STATICVALUEFACTORY; break;
             case ERROR       : flag = 0; nextToken(); break;
             default: break loop;
             }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java	Tue Jan 30 14:45:14 2018 +0530
@@ -163,6 +163,9 @@
         THROWS("throws"),
         TRANSIENT("transient"),
         TRY("try"),
+        VALUE("__ByValue"),
+        STATICVALUEFACTORY("__ValueFactory"),
+        VDEFAULT("__MakeDefault"),
         VOID("void", Tag.NAMED),
         VOLATILE("volatile"),
         WHILE("while"),
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Jan 30 14:45:14 2018 +0530
@@ -353,6 +353,10 @@
     cyclic inheritance involving {0}
 
 # 0: symbol
+compiler.err.cyclic.value.type.membership=\
+    cyclic value type membership involving {0}
+
+# 0: symbol
 compiler.err.cyclic.annotation.element=\
     type of element {0} is cyclic
 
@@ -2696,6 +2700,9 @@
 compiler.misc.feature.private.intf.methods=\
     private interface methods
 
+compiler.misc.feature.value.types=\
+    value types
+
 compiler.warn.underscore.as.identifier=\
     as of release 9, ''_'' is a keyword, and may not be used as an identifier
 
@@ -3174,3 +3181,66 @@
 # 0: string, 1: string
 compiler.err.illegal.argument.for.option=\
     illegal argument for {0}: {1}
+
+
+compiler.err.garbled.value.reference.instantiation=\
+    Mismatched instantiation syntax between value and reference types.
+
+# 0: name (of method)
+compiler.err.value.does.not.support=\
+    value types do not support {0}
+
+compiler.err.value.must.be.final=\
+    value type must be declared final
+
+compiler.err.value.field.must.be.final=\
+    value-type field must be declared final
+
+compiler.err.value.factory.must.be.static=\
+    Value factory must be a static method
+
+compiler.err.invalid.arguments.to.make.default=\
+    Superfluous arguments to default value creation
+
+compiler.err.make.default.in.nonfactory=\
+    Illegal attempt to create a default value outside of value factory
+
+compiler.err.make.default.with.nonvalue=\
+    Default value creation requires a value type
+
+# 0: symbol
+compiler.err.make.default.with.wrong.value.type=\
+    This value factory cannot create values of type {0}
+
+compiler.err.value.may.not.extend=\
+    value type may not extend another value or class
+
+# 0: name (of method)
+compiler.warn.value.does.not.support=\
+    value types do not support {0}
+
+compiler.warn.value.must.be.final=\
+    value type must be declared final
+
+compiler.warn.value.field.must.be.final=\
+    value-type field must be declared final
+
+compiler.warn.value.may.not.extend=\
+    value type may not extend another value or class
+
+compiler.warn.mod.not.allowed.here=\
+    modifier {0} not allowed here
+
+# 0: message segment or type, 1: message segment
+compiler.warn.type.found.req=\
+    unexpected type\n\
+    required: {1}\n\
+    found:    {0}
+
+# 0: type, 1: type
+compiler.warn.incomparable.types=\
+    incomparable types: {0} and {1}
+
+# 0: symbol
+compiler.warn.cyclic.value.type.membership=\
+    cyclic value type membership involving {0}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue Jan 30 14:45:14 2018 +0530
@@ -1669,6 +1669,7 @@
         public JCExpression clazz;
         public List<JCExpression> args;
         public JCClassDecl def;
+        public CreationMode creationMode;    // <- temporary
         public Symbol constructor;
         public Type varargsElement;
         public Type constructorType;
@@ -1684,6 +1685,7 @@
             this.clazz = clazz;
             this.args = args;
             this.def = def;
+            this.creationMode = CreationMode.NEW;    // <- temporary
         }
         @Override
         public void accept(Visitor v) { v.visitNewClass(this); }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Tue Jan 30 14:45:14 2018 +0530
@@ -99,6 +99,7 @@
     public final Name getMessage;
     public final Name hasNext;
     public final Name hashCode;
+    public final Name identityHashCode;
     public final Name init;
     public final Name initCause;
     public final Name iterator;
@@ -120,6 +121,7 @@
     public final Name java_lang_Enum;
     public final Name java_lang_Object;
     public final Name java_lang_invoke_MethodHandle;
+    public final Name java_lang_System;
 
     // names of builtin classes
     public final Name Array;
@@ -261,6 +263,7 @@
         getMessage = fromString("getMessage");
         hasNext = fromString("hasNext");
         hashCode = fromString("hashCode");
+        identityHashCode = fromString("identityHashCode");
         init = fromString("<init>");
         initCause = fromString("initCause");
         iterator = fromString("iterator");
@@ -283,6 +286,7 @@
         java_lang_Enum = fromString("java.lang.Enum");
         java_lang_Object = fromString("java.lang.Object");
         java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
+        java_lang_System = fromString("java.lang.System");
 
         // names of builtin classes
         Array = fromString("Array");
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Tue Jan 30 14:45:14 2018 +0530
@@ -89,6 +89,7 @@
 import jdk.javadoc.internal.doclets.toolkit.WorkArounds;
 import jdk.javadoc.internal.tool.DocEnvImpl;
 
+import static com.sun.source.doctree.DocTree.Kind.VALUE;
 import static javax.lang.model.element.ElementKind.*;
 import static javax.lang.model.element.Modifier.*;
 import static javax.lang.model.type.TypeKind.*;
--- a/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Thu Jan 11 10:15:53 2018 +0100
+++ b/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java	Tue Jan 30 14:45:14 2018 +0530
@@ -198,6 +198,9 @@
         ERROR(TokenKind.ERROR, XERRO),  //
         IDENTIFIER(TokenKind.IDENTIFIER, XEXPR1|XDECL1|XTERM),  //
         UNDERSCORE(TokenKind.UNDERSCORE, XERRO),  //  _
+        VALUE(TokenKind.VALUE, XEXPR1|XDECL1|XTERM),  //  "__ByValue"
+        VALUEFACTORY(TokenKind.STATICVALUEFACTORY, XDECL1),  //  "__ValueFactory" (a la public)
+        VDEFAULT(TokenKind.VDEFAULT, XEXPR1|XDECL1|XTERM),  //  "__MakeDefault" a la __Make
         CLASS(TokenKind.CLASS, XEXPR|XDECL1|XBRACESNEEDED),  //  class decl (MAPPED: DOTCLASS)
         MONKEYS_AT(TokenKind.MONKEYS_AT, XEXPR|XDECL1),  //  @
         IMPORT(TokenKind.IMPORT, XDECL1|XSTART),  //  import -- consider declaration
--- a/test/langtools/tools/javac/diags/examples.not-yet.txt	Thu Jan 11 10:15:53 2018 +0100
+++ b/test/langtools/tools/javac/diags/examples.not-yet.txt	Tue Jan 30 14:45:14 2018 +0530
@@ -154,3 +154,24 @@
 compiler.err.locn.module-info.not.allowed.on.patch.path
 compiler.misc.cant.resolve.modules
 compiler.misc.file.does.not.contain.module
+
+# Value types
+compiler.err.cyclic.value.type.membership
+compiler.err.garbled.value.reference.instantiation
+compiler.err.value.does.not.support
+compiler.err.value.factory.must.be.static
+compiler.err.value.field.must.be.final
+compiler.err.value.must.be.final
+compiler.err.invalid.arguments.to.make.default
+compiler.err.make.default.in.nonfactory
+compiler.err.make.default.with.nonvalue
+compiler.err.make.default.with.wrong.value.type
+compiler.err.value.may.not.extend
+compiler.warn.cyclic.value.type.membership
+compiler.warn.incomparable.types
+compiler.warn.mod.not.allowed.here
+compiler.warn.type.found.req
+compiler.warn.value.does.not.support
+compiler.warn.value.field.must.be.final
+compiler.warn.value.may.not.extend
+compiler.warn.value.must.be.final
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/ValuesNotSupported.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018, 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.
+ *
+ * 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.
+ */
+
+// key: compiler.err.feature.not.supported.in.source
+// key: compiler.misc.feature.value.types
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 10
+
+__ByValue final class ValuesNotSupported {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckClone.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types do not support clone
+ *
+ * @compile/fail/ref=CheckClone.out -XDrawDiagnostics CheckClone.java
+ */
+
+final __ByValue class CheckClone {
+    final __ByValue class InnerValue {
+        void foo(InnerValue iv) {
+            iv.clone();
+            clone();
+        }
+    }
+    void foo(CheckClone v) {
+        v.clone();
+        clone();
+    }
+    @Override
+    protected Object clone() { return null; }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckClone.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,5 @@
+CheckClone.java:11:21: compiler.err.value.does.not.support: clone
+CheckClone.java:12:18: compiler.err.value.does.not.support: clone
+CheckClone.java:16:16: compiler.err.value.does.not.support: clone
+CheckClone.java:17:14: compiler.err.value.does.not.support: clone
+4 errors
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckCyclicMembership.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types may not declare fields of its own type either directly or indirectly.
+ *
+ * @compile/fail/ref=CheckCyclicMembership.out -XDrawDiagnostics CheckCyclicMembership.java
+ */
+
+final __ByValue class CheckCyclicMembership {
+    class InnerRef {
+        CheckCyclicMembership ccm;
+    }
+    __ByValue final class InnerValue {
+        final CheckCyclicMembership ccm = __MakeDefault CheckCyclicMembership(); // Error.
+    }
+    final CheckCyclicMembership ccm = __MakeDefault CheckCyclicMembership(); // Error.
+    final int i = 10;
+    final String s = "blah";
+    final InnerRef ir = new InnerRef(); // OK.
+    final InnerValue iv = __MakeDefault InnerValue(); // Error. Some Order dependancy hides this. FIXME.
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckCyclicMembership.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,3 @@
+CheckCyclicMembership.java:15:33: compiler.err.cyclic.value.type.membership: CheckCyclicMembership
+CheckCyclicMembership.java:13:37: compiler.err.cyclic.value.type.membership: CheckCyclicMembership.InnerValue
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckEquals.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types do not support == or !=
+ *
+ * @compile/fail/ref=CheckEquals.out -XDrawDiagnostics CheckEquals.java
+ */
+
+final __ByValue class CheckEquals {
+    boolean foo(CheckEquals a, CheckEquals b) {
+        return (a == b) || (a != b);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckEquals.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,3 @@
+CheckEquals.java:10:19: compiler.err.value.does.not.support: ==
+CheckEquals.java:10:31: compiler.err.value.does.not.support: !=
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckExtends.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,9 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Values may not extend
+ *
+ * @compile/fail/ref=CheckExtends.out -XDrawDiagnostics CheckExtends.java
+ */
+
+final __ByValue class CheckExtends extends Object {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckExtends.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,2 @@
+CheckExtends.java:8:17: compiler.err.value.may.not.extend
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckFinal.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types and their instance fields must be final
+ *
+ * @compile/fail/ref=CheckFinal.out -XDrawDiagnostics CheckFinal.java
+ */
+
+__ByValue class CheckFinal {  // <- error
+    int x;          // <- error
+    void f(int x) { // <- ok
+        int y;      // <- ok
+        __ByValue final class CheckLocalFinal {
+            int x; // <- error.
+        }
+    }
+    final Object o = new Object() { int i; }; // <- ok
+    static int xs; // OK.
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckFinal.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,4 @@
+CheckFinal.java:8:11: compiler.err.value.must.be.final
+CheckFinal.java:9:9: compiler.err.value.field.must.be.final
+CheckFinal.java:13:17: compiler.err.value.field.must.be.final
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckFinalize.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types do not support finalize
+ *
+ * @compile/fail/ref=CheckFinalize.out -XDrawDiagnostics CheckFinalize.java
+ */
+
+final __ByValue class CheckFinalize {
+    @Override
+    protected void finalize() {}
+
+    final __ByValue class CheckFinalizeInner {}
+
+    void foo(CheckFinalizeInner cfi, CheckFinalize cf) {
+        cfi.finalize();          // Error
+        cf.finalize();           // Error.
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckFinalize.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,6 @@
+CheckFinalize.java:15:12: compiler.err.report.access: finalize(), protected, java.lang.Object
+CheckFinalize.java:15:21: compiler.err.value.does.not.support: finalize
+CheckFinalize.java:16:20: compiler.err.value.does.not.support: finalize
+- compiler.note.deprecated.filename: CheckFinalize.java
+- compiler.note.deprecated.recompile
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types do not support identityHashCode
+ *
+ * @compile/fail/ref=CheckIdentityHash.out -XDrawDiagnostics CheckIdentityHash.java
+ */
+
+final __ByValue class CheckIdentityHash {
+    int identityHashCode(CheckIdentityHash x) {
+        return 0;
+    }
+    void test(CheckIdentityHash v) {
+        this.identityHashCode(v);      // <- ok
+        System.identityHashCode(v);    // <- error
+        System.identityHashCode(this); // <- error
+        java.lang.System.identityHashCode(v);    // <- error
+        java.lang.System.identityHashCode(this); // <- error
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,5 @@
+CheckIdentityHash.java:14:32: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash.java:15:32: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash.java:16:42: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash.java:17:42: compiler.err.value.does.not.support: identityHashCode
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash01.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Value types do not support identityHashCode
+ *
+ * @compile/fail/ref=CheckIdentityHash01.out -XDrawDiagnostics CheckIdentityHash01.java
+ */
+
+import static java.lang.System.*;
+
+final __ByValue class CheckIdentityHash01 {
+    void test(CheckIdentityHash01 v) {
+
+        identityHashCode(v);      // <- error
+        identityHashCode(this);   // <- error
+
+        System system = null;
+        system.identityHashCode(v);      // <- error
+        system.identityHashCode(this);   // <- error
+
+        System.identityHashCode(v);      // <- error
+        System.identityHashCode(this);   // <- error
+
+        java.lang.System.identityHashCode(v);    // <- error
+        java.lang.System.identityHashCode(this); // <- error
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckIdentityHash01.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,9 @@
+CheckIdentityHash01.java:13:25: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:14:25: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:17:32: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:18:32: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:20:32: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:21:32: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:23:42: compiler.err.value.does.not.support: identityHashCode
+CheckIdentityHash01.java:24:42: compiler.err.value.does.not.support: identityHashCode
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckMakeDefault.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Check various semantic constraints on value creation via __MakeDefault
+ *
+ * @compile/fail/ref=CheckMakeDefault.out -XDrawDiagnostics CheckMakeDefault.java
+ */
+__ByValue final class Point {
+
+    static final class Sinner {
+        __ValueFactory static Sinner make() {
+            return __MakeDefault Sinner(); // NO: Sinner is not a value class.
+        }
+    }
+
+    __ByValue static final class SinnerValue {
+        __ValueFactory static SinnerValue make() {
+            return __MakeDefault SinnerValue(); // OK.
+        }
+    }
+
+    final int x;
+    final int y;
+
+    Point() {}
+    Point (int x, int y) {}
+
+    Point badFactory(int x, int y) {
+        return __MakeDefault Point(); // NO: Value created in a non-factory.
+    }
+
+    __ValueFactory static Point make(int x, int y) {
+       Point p = __MakeDefault Point(10, 20); // NO arguments to default value creation
+       String s = __MakeDefault String(); // NO: String cannot be produced in this factory.
+       __MakeDefault SinnerValue(); // NO: Wrong factory.
+       p = __MakeDefault Point();
+       p.x = x;
+       p.y = y;
+       return p;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckMakeDefault.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,6 @@
+CheckMakeDefault.java:11:20: compiler.err.make.default.with.nonvalue
+CheckMakeDefault.java:28:16: compiler.err.make.default.in.nonfactory
+CheckMakeDefault.java:32:18: compiler.err.invalid.arguments.to.make.default
+CheckMakeDefault.java:33:19: compiler.err.make.default.with.nonvalue
+CheckMakeDefault.java:34:8: compiler.err.make.default.with.wrong.value.type: Point.SinnerValue
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckNullAssign.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Assignment of null to value types should be disallowed.
+ *
+ * @compile/fail/ref=CheckNullAssign.out -XDrawDiagnostics CheckNullAssign.java
+ */
+
+final __ByValue class CheckNullAssign {
+    CheckNullAssign foo(CheckNullAssign cna) {
+        // All of the below involve subtype/assignability checks and should be rejected.
+        cna = null;
+        foo(null);
+        if (null instanceof CheckNullAssign) {}
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckNullAssign.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,5 @@
+CheckNullAssign.java:11:15: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign)
+CheckNullAssign.java:12:9: compiler.err.cant.apply.symbol: kindname.method, foo, CheckNullAssign, compiler.misc.type.null, kindname.class, CheckNullAssign, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign))
+CheckNullAssign.java:13:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign)
+CheckNullAssign.java:14:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullAssign)
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckNullCastable.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary null cannot be casted to and compared with value types.
+ *
+ * @compile/fail/ref=CheckNullCastable.out -XDrawDiagnostics CheckNullCastable.java
+ */
+
+__ByValue final class CheckNullCastable {
+    void foo(CheckNullCastable cnc) {
+        CheckNullCastable cncl = (CheckNullCastable) null;
+        if (cnc != null) {};
+        if (null != cnc) {};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckNullCastable.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,4 @@
+CheckNullCastable.java:10:54: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, CheckNullCastable)
+CheckNullCastable.java:11:17: compiler.err.incomparable.types: CheckNullCastable, compiler.misc.type.null
+CheckNullCastable.java:12:18: compiler.err.incomparable.types: compiler.misc.type.null, CheckNullCastable
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckStaticValueFactory.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,53 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Check various semantic constraints on static value factory method
+ *
+ * @compile/fail/ref=CheckStaticValueFactory.out -XDrawDiagnostics CheckStaticValueFactory.java
+ */
+__ByValue __ValueFactory final class Point { // NO: A type cannot be __ValueFactory
+
+    static class Sinner {
+        final int x;
+    }
+
+    interface I {
+        default __ValueFactory I foo() { // No: an interface method cannot be value factory
+            return null;
+        }
+    }
+
+    __ValueFactory final int x; // NO: A field cannot be value factory
+
+    final int y;
+    final int z = 0;
+
+    __ValueFactory Point() { // NO: A constructor cannot be value factory
+    }
+
+    __ValueFactory Point badFactory(int x, int y) { // No: factory must be a static method
+        return __MakeDefault Point();
+    }
+
+    __ValueFactory static String makeString(int x, int y) { // NO: bad return type for factory
+        String s = __MakeDefault String(); // NO: String is not a value type
+        return s;
+    }
+
+    __ValueFactory static Point make(int x, int y, int z) {
+       Point p = __MakeDefault Point();
+       p.x = x; // OK: allow update to blank final field via copy on write`
+       p.y = y; // OK: allow update to blank final field via copy on write`
+       p.z = z; // !OK, do not allow update to a non blank final even in a value factory.
+       Sinner s = new Sinner();
+       s.x = 10; // NO: No write to final field.
+       return p;
+    }
+
+    static Point nonFactory(int x, int y, int z) {
+       Point p = __MakeDefault Point(); // NO: cannot create default value in non-factory
+       p.x = x; // Error: No write to final field.
+       p.y = y; // Error: No write to final field.
+       p.z = z; // Error: No write to final field.
+       return p;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckStaticValueFactory.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,14 @@
+CheckStaticValueFactory.java:7:32: compiler.err.mod.not.allowed.here: staticvaluefactory
+CheckStaticValueFactory.java:19:30: compiler.err.mod.not.allowed.here: staticvaluefactory
+CheckStaticValueFactory.java:24:20: compiler.err.mod.not.allowed.here: staticvaluefactory
+CheckStaticValueFactory.java:27:26: compiler.err.value.factory.must.be.static
+CheckStaticValueFactory.java:31:27: compiler.err.type.found.req: java.lang.String, Point
+CheckStaticValueFactory.java:14:34: compiler.err.mod.not.allowed.here: staticvaluefactory
+CheckStaticValueFactory.java:32:20: compiler.err.make.default.with.nonvalue
+CheckStaticValueFactory.java:40:9: compiler.err.cant.assign.val.to.final.var: z
+CheckStaticValueFactory.java:42:9: compiler.err.cant.assign.val.to.final.var: x
+CheckStaticValueFactory.java:47:18: compiler.err.make.default.in.nonfactory
+CheckStaticValueFactory.java:48:9: compiler.err.cant.assign.val.to.final.var: x
+CheckStaticValueFactory.java:49:9: compiler.err.cant.assign.val.to.final.var: y
+CheckStaticValueFactory.java:50:9: compiler.err.cant.assign.val.to.final.var: z
+13 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckSuperCompileOnly.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015 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.
+ */
+
+/*
+ * @test
+ * @summary Check that value types have their super types wired to be j.l.Object
+ *
+ * @compile Point.java
+ * @compile CheckSuperCompileOnly.java
+ */
+
+public class CheckSuperCompileOnly {
+    public static void main(String... args) {
+        final Point p = Point.makePoint(100, 200);
+        Object v = p;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckSync.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,41 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary May not synchronize on value types
+ *
+ * @compile/fail/ref=CheckSync.out -XDrawDiagnostics CheckSync.java
+ */
+
+/* Note: ATM, value types do not have jlO in their lineage. So they anyway
+   cannot synchronize using the methods declared on jlO.
+*/
+
+public final __ByValue class CheckSync {
+
+    final __ByValue class Val {
+
+        void foo() {
+            // All calls below are bad.
+            wait();
+            wait(10);
+            wait(10, 10);
+            notify();
+            notifyAll();
+            finalize();
+            clone();
+        }
+    }
+
+    final Val val = __MakeDefault Val();
+
+    void test() throws InterruptedException {
+        // All calls below are bad.
+        val.wait();
+        val.wait(10);
+        val.wait(new Integer(10));
+        val.wait(new Long(10));
+        val.wait(10L);
+        val.wait(10L, 10);
+        val.notify();
+        val.notifyAll();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckSync.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,18 @@
+CheckSync.java:18:17: compiler.err.value.does.not.support: wait
+CheckSync.java:19:17: compiler.err.value.does.not.support: wait
+CheckSync.java:20:17: compiler.err.value.does.not.support: wait
+CheckSync.java:21:19: compiler.err.value.does.not.support: notify
+CheckSync.java:22:22: compiler.err.value.does.not.support: notifyAll
+CheckSync.java:23:21: compiler.err.value.does.not.support: finalize
+CheckSync.java:24:18: compiler.err.value.does.not.support: clone
+CheckSync.java:32:17: compiler.err.value.does.not.support: wait
+CheckSync.java:33:17: compiler.err.value.does.not.support: wait
+CheckSync.java:34:17: compiler.err.value.does.not.support: wait
+CheckSync.java:35:17: compiler.err.value.does.not.support: wait
+CheckSync.java:36:17: compiler.err.value.does.not.support: wait
+CheckSync.java:37:17: compiler.err.value.does.not.support: wait
+CheckSync.java:38:19: compiler.err.value.does.not.support: notify
+CheckSync.java:39:22: compiler.err.value.does.not.support: notifyAll
+- compiler.note.deprecated.filename: CheckSync.java
+- compiler.note.deprecated.recompile
+15 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckSynchronized.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Check behavior of synzhronized key word on value instances and methods.
+ *
+ * @compile/fail/ref=CheckSynchronized.out -XDrawDiagnostics CheckSynchronized.java
+ */
+
+__ByValue final class CheckSynchronized {
+    synchronized void foo() { // <<-- ERROR, no monitor associated with `this'
+    }
+    void goo() {
+        synchronized(this) {} // <<-- ERROR, no monitor associated with `this'
+    }
+    synchronized static void zoo(CheckSynchronized cs) { // OK, static method.
+        synchronized(cs) {    // <<-- ERROR, no monitor associated with value instance.
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckSynchronized.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,4 @@
+CheckSynchronized.java:9:23: compiler.err.mod.not.allowed.here: synchronized
+CheckSynchronized.java:12:9: compiler.err.type.found.req: CheckSynchronized, (compiler.misc.type.req.ref)
+CheckSynchronized.java:15:9: compiler.err.type.found.req: CheckSynchronized, (compiler.misc.type.req.ref)
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckValueFactoryWithReference.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Do not allow mismatched instantiation syntax between value & reference types.
+ *
+ * @compile/fail/ref=CheckValueFactoryWithReference.out -XDrawDiagnostics CheckValueFactoryWithReference.java
+ */
+
+final class CheckValueFactoryWithReference {
+    final Object o = __MakeDefault Object();
+    __ByValue final class Point {}
+    Point p = new Point();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckValueFactoryWithReference.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,3 @@
+CheckValueFactoryWithReference.java:9:22: compiler.err.make.default.with.nonvalue
+CheckValueFactoryWithReference.java:11:15: compiler.err.garbled.value.reference.instantiation
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckValueModifier.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Compiler should reject value modifier when it features in illegal contexts.
+ *
+ * @compile/fail/ref=CheckValueModifier.out -XDrawDiagnostics CheckValueModifier.java
+ */
+
+/* Note: __ByValue as a modifier will be rejected by the parser if it features as a
+   modifier of a (a) catch parameter, (b) resource variable, (c) for loop's init section
+   declarators and (d) formal parameters. We test here only for the other illegal places.
+
+   All uses of __ByValue below should trigger errors.
+*/
+class CheckValueModifier {
+   __ByValue int x;
+   __ByValue int foo() {
+       __ByValue String local;
+   }
+   __ByValue interface IFace {}
+   __ByValue @interface Annot {}
+   __ByValue enum Enum {}
+   __ByValue abstract class Inner {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/CheckValueModifier.out	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,8 @@
+CheckValueModifier.java:19:14: compiler.err.illegal.combination.of.modifiers: interface, value
+CheckValueModifier.java:20:15: compiler.err.illegal.combination.of.modifiers: interface, value
+CheckValueModifier.java:21:14: compiler.err.mod.not.allowed.here: value
+CheckValueModifier.java:22:23: compiler.err.illegal.combination.of.modifiers: abstract, value
+CheckValueModifier.java:15:18: compiler.err.mod.not.allowed.here: value
+CheckValueModifier.java:16:18: compiler.err.mod.not.allowed.here: value
+CheckValueModifier.java:17:25: compiler.err.mod.not.allowed.here: value
+7 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/valhalla/lworld-values/Point.java	Tue Jan 30 14:45:14 2018 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/*
+ * @test
+ * @summary Test basic syntax of values
+ *
+ * @compile Point.java
+ */
+
+final __ByValue class Point {
+    static final Point origin = makePoint(10, 20);
+    final int x;
+    final int y;
+    Point () {
+        x = 10;
+        y = 20;
+    }
+    __ValueFactory static Point makePoint(int x, int y) {
+        Point p = __MakeDefault Point();
+        p.x = x;
+        p.y = y;
+        return p;
+    }
+}
\ No newline at end of file