changeset 3265:5de3c2615ab6

Enhancement: Folding TransValues into Attr, TypeEnter Contributed-by: srikanth.adayapalam@oracle.com
author mcimadamore
date Wed, 02 Dec 2015 16:00:08 +0000
parents 018ef6762d6e
children 358b7a32d810
files 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/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransValues.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.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/util/Names.java test/tools/javac/Object1.out test/tools/javac/Object2.out test/tools/javac/diags/examples/NoSuperTypesForJLO.java test/tools/javac/valhalla/values/CheckClone.java test/tools/javac/valhalla/values/CheckClone.out test/tools/javac/valhalla/values/CheckFinalize.java test/tools/javac/valhalla/values/CheckFinalize.out test/tools/javac/valhalla/values/CheckIdentityHash.java test/tools/javac/valhalla/values/CheckIdentityHash.out test/tools/javac/valhalla/values/CheckIdentityHash01.java test/tools/javac/valhalla/values/CheckIdentityHash01.out test/tools/javac/valhalla/values/CheckSync.java test/tools/javac/valhalla/values/CheckSync.out
diffstat 22 files changed, 221 insertions(+), 201 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Dec 02 16:00:08 2015 +0000
@@ -387,6 +387,10 @@
         return name.isEmpty();
     }
 
+    public boolean isValue() {
+        return type.isValue();
+    }
+
     /** Is this symbol a constructor?
      */
     public boolean isConstructor() {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Dec 02 16:00:08 2015 +0000
@@ -288,6 +288,28 @@
         };
     }
 
+    public void synthesizeJavaLangValueClassIfMissing(final Type type) {
+        final Completer completer = type.tsym.completer;
+        type.tsym.completer = new Completer() {
+            public void complete(Symbol sym) throws CompletionFailure {
+                try {
+                    completer.complete(sym);
+                } catch (CompletionFailure e) {
+                    sym.flags_field |= PUBLIC;
+                    ((ClassType) sym.type).supertype_field = Type.noType;
+                    ((ClassSymbol) sym).members_field = WriteableScope.create(sym);
+                    sym.members().enter(new MethodSymbol(PUBLIC, names.init,
+                            new MethodType(List.<Type>nil(), voidType, List.<Type>nil(), methodClass), sym));
+                }
+            }
+
+            @Override
+            public boolean isTerminal() {
+                return completer.isTerminal();
+            }
+        };
+    }
+
     public void synthesizeEmptyBSMIfMissing(final Type type) {
         final Completer completer = type.tsym.completer;
         if (completer != null) {
@@ -517,7 +539,7 @@
         synthesizeEmptyInterfaceIfMissing(varHandleType);
         synthesizeEmptyInterfaceIfMissing(fieldHandleType);
         synthesizeEmptyInterfaceIfMissing(arrayHandleType);
-        synthesizeEmptyInterfaceIfMissing(valueClassType);
+        synthesizeJavaLangValueClassIfMissing(valueClassType);
 
         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
         synthesizeEmptyInterfaceIfMissing(cloneableType);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Dec 02 16:00:08 2015 +0000
@@ -1059,8 +1059,8 @@
             } else {
                 // Add an implicit super() call unless an explicit call to
                 // super(...) or this(...) is given
-                // or we are compiling class java.lang.Object.
-                if (tree.name == names.init && owner.type != syms.objectType) {
+                // or we are compiling class java.lang.{Object, Value}.
+                if (tree.name == names.init && owner.type != syms.objectType && owner.type != syms.valueClassType) {
                     JCBlock body = tree.body;
                     if (body.stats.isEmpty() ||
                             !TreeInfo.isSelfCall(body.stats.head)) {
@@ -1123,6 +1123,9 @@
                 annotate.queueScanTreeAndTypeAnnotate(tree.init, env, tree.sym, tree.pos());
                 annotate.flush();
             }
+            if (tree.sym.owner.type.isValue() && (tree.mods.flags & Flags.FINAL) == 0) {
+                log.error(tree.pos(), "value.field.must.be.final");
+            }
         }
 
         VarSymbol v = tree.sym;
@@ -1930,6 +1933,13 @@
                     : env.enclClass.sym.type;
             restype = adjustMethodReturnType(qualifier, methName, argtypes, restype);
 
+            // 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 && tree.args.head.type.isValue())
+                    log.error(tree.pos(), "value.does.not.support", "identityHashCode");
+            }
+
             // 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);
@@ -3239,6 +3249,9 @@
                 if (!types.isCastable(left, right, new Warner(tree.pos()))) {
                     log.error(tree.pos(), "incomparable.types", left, right);
                 }
+                if (left.isValue() || right.isValue()) {
+                    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/Resolve.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Dec 02 16:00:08 2015 +0000
@@ -3574,6 +3574,29 @@
             if (name == names.error)
                 return null;
 
+            /* If this is an ill conceived attempt to invoke jlO methods not available on value types,
+               issue a distinct message that spells out the programmer's error.
+            */
+            if (kind == ABSENT_MTH && site.isValue()) {
+                int argSize = argtypes.size();
+                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))))) {
+                            return diags.create(dkind, log.currentSource(), pos,
+                                    "value.does.not.support", name);
+                        }
+                        break;
+                    case "notify":
+                    case "notifyAll":
+                    case "clone":
+                    case "finalize":
+                        return diags.create(dkind, log.currentSource(), pos,
+                                "value.does.not.support", name);
+                }
+            }
+
             boolean hasLocation = false;
             if (location == null) {
                 location = site.tsym;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransValues.java	Tue Nov 24 18:29:55 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.tools.javac.comp;
-
-import com.sun.tools.javac.code.*;
-import static com.sun.tools.javac.code.Kinds.Kind.*;
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.util.*;
-
-/**
- * Check and modify classes marked with the VALUE modifier.
- *
- * see: http://cr.openjdk.java.net/~jrose/values/values-0.html
- *
- */
-
-public class TransValues extends TreeTranslator {
-    protected static final Context.Key<TransValues> transValuesKey = new Context.Key<>();
-
-    public static TransValues instance(Context context) {
-        TransValues instance = context.get(transValuesKey);
-        if (instance == null)
-            instance = new TransValues(context);
-        return instance;
-    }
-
-    private Log log;
-    private Names names;
-    private TreeMaker make;
-    private Symtab syms;
-
-    protected TransValues(Context context) {
-        context.put(transValuesKey, this);
-        log = Log.instance(context);
-        names = Names.instance(context);
-        syms = Symtab.instance(context);
-    }
-
-    public JCTree translateTopLevelClass(JCTree cdef, TreeMaker make) {
-        this.make = make;
-        return translate(cdef);
-    }
-
-    private boolean inValue = false;
-    private boolean inMethod = false;
-
-    public void visitClassDef(JCClassDecl tree) {
-        boolean oldInValue = inValue;
-        try {
-            inValue = (tree.mods.flags & Flags.VALUE) != 0;
-            if (inValue) {
-                if (tree.extending != null) {
-                    log.error(tree.pos(), "value.may.not.extend");
-                }
-                if ((tree.mods.flags & Flags.FINAL) == 0) {
-                    log.error(tree.pos(), "value.must.be.final");
-                }
-
-                if (tree.sym.fullname == names.java_lang_Value) {
-                    ((Type.ClassType)tree.type).supertype_field = Type.noType;
-                    tree.extending = null;
-                } else {
-                    // set super class to java.lang.Value
-                    ((Type.ClassType)tree.type).supertype_field = syms.valueClassType;
-                    tree.extending = make.Ident(syms.valueClassType.tsym);
-                    ((JCIdent)tree.extending).sym = syms.valueClassType.tsym;
-                    tree.extending.type = syms.valueClassType;
-                }
-            }
-            super.visitClassDef(tree);
-        }
-        finally {
-            inValue = oldInValue;
-        }
-    }
-    public void visitMethodDef(JCMethodDecl tree) {
-        if (inValue && tree.name == names.finalize) {
-            log.error(tree.pos(), "value.does.not.support", "finalize");
-        }
-        if (inValue && tree.name == names.clone) {
-            log.error(tree.pos(), "value.does.not.support", "clone");
-        }
-        super.visitMethodDef(tree);
-    }
-    public void visitVarDef(JCVariableDecl tree) {
-        if (inValue && tree.sym.owner.kind == TYP && (tree.mods.flags & Flags.FINAL) == 0) {
-            log.error(tree.pos(), "value.field.must.be.final");
-        }
-        super.visitVarDef(tree);
-    }
-
-    public void visitApply(JCMethodInvocation tree) {
-        if (inValue) {
-            // change Object.super() => Value.super()
-            if (tree.meth.hasTag(Tag.IDENT)) {
-                JCIdent id = (JCIdent)tree.meth;
-                if (id.name == names._super)
-                    id.sym = id.sym.clone(syms.valueClassType.tsym);
-            }
-        }
-        // check for System.identityHashCode(value)
-        if (tree.meth.hasTag(Tag.SELECT)) {
-            JCFieldAccess m = (JCFieldAccess)tree.meth;
-            if (m.selected.hasTag(Tag.IDENT)) {
-                JCIdent id = (JCIdent)m.selected;
-                if ((tree.args.length() == 1) &&
-                    ((tree.args.head.type.tsym.flags() & Flags.VALUE) != 0) &&
-                    id.name.contentEquals("System") &&
-                    m.name.contentEquals("identityHashCode"))
-                {
-                    log.error(tree.pos(), "value.does.not.support", "identityHashCode");
-                }
-            }
-        }
-        super.visitApply(tree);
-    }
-
-    // check for invalid method selections
-    public void visitSelect(JCFieldAccess tree) {
-        if ((tree.selected.type.tsym.flags() & Flags.VALUE) != 0) {
-            checkMethod(tree, "notify");
-            checkMethod(tree, "notifyAll");
-            checkMethod(tree, "wait");
-        }
-        super.visitSelect(tree);
-    }
-    private void checkMethod(JCFieldAccess tree, String name) {
-        if (tree.name.contentEquals(name)) {
-            log.error(tree.pos(), "value.does.not.support", name);
-        }
-    }
-
-    public void visitBinary(JCBinary tree) {
-        if (tree.operator.name.contentEquals("==") ||
-            tree.operator.name.contentEquals("!="))
-        {
-            if ((tree.lhs.type.tsym.flags() & Flags.VALUE) != 0 ||
-                (tree.rhs.type.tsym.flags() & Flags.VALUE) != 0)
-                log.error(tree.pos(), "value.does.not.support", tree.operator.name.toString());
-        }
-        super.visitBinary(tree);
-    }
-}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Wed Dec 02 16:00:08 2015 +0000
@@ -641,8 +641,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 {
@@ -650,9 +653,9 @@
                 supertype = ((tree.mods.flags & Flags.ENUM) != 0)
                 ? attr.attribBase(enumBase(tree.pos, sym), baseEnv,
                                   true, false, false)
-                : (sym.fullname == names.java_lang_Object)
+                : (sym.fullname == names.java_lang_Object || sym.fullname == names.java_lang_Value)
                 ? Type.noType
-                : syms.objectType;
+                : isValueType ? syms.valueClassType : syms.objectType;
             }
             ct.supertype_field = modelMissingTypes(supertype, extending, false);
 
@@ -720,14 +723,9 @@
             attribSuperTypes(env, baseEnv);
 
             if (sym.fullname == names.java_lang_Object) {
-                if (tree.extending != null) {
-                    chk.checkNonCyclic(tree.extending.pos(),
-                                       ct.supertype_field);
+                if (tree.extending != null || tree.implementing.nonEmpty()) {
+                    log.error(tree.pos(), "jlo.cannot.declare.supertypes");
                     ct.supertype_field = Type.noType;
-                }
-                else if (tree.implementing.nonEmpty()) {
-                    chk.checkNonCyclic(tree.implementing.head.pos(),
-                                       ct.interfaces_field.head);
                     ct.interfaces_field = List.nil();
                 }
             }
@@ -824,6 +822,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");
+            }
         }
     }
 
@@ -1012,7 +1013,7 @@
                 argtypes, based);
         List<JCVariableDecl> params = make.Params(argtypes, init);
         List<JCStatement> stats = List.nil();
-        if (c.type != syms.objectType) {
+        if (c.type != syms.objectType && c.type != syms.valueClassType) {
             stats = stats.prepend(SuperCall(make, typarams, params, based));
         }
         result = make.MethodDef(init, make.Block(0, stats));
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Dec 02 16:00:08 2015 +0000
@@ -277,10 +277,6 @@
      */
     protected Flow flow;
 
-    /** The value type checks.
-     */
-    protected TransValues transValues;
-
     /** The type eraser.
      */
     protected TransTypes transTypes;
@@ -383,7 +379,6 @@
         chk = Check.instance(context);
         gen = Gen.instance(context);
         flow = Flow.instance(context);
-        transValues = TransValues.instance(context);
         transTypes = TransTypes.instance(context);
         lower = Lower.instance(context);
         annotate = Annotate.instance(context);
@@ -1483,7 +1478,6 @@
             if (shouldStop(CompileState.TRANSTYPES))
                 return;
 
-            env.tree = transValues.translateTopLevelClass(env.tree, localMake);
             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
             compileStates.put(env, CompileState.TRANSTYPES);
 
@@ -1692,7 +1686,6 @@
         chk = null;
         gen = null;
         flow = null;
-        transValues = null;
         transTypes = null;
         lower = null;
         annotate = null;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Dec 02 16:00:08 2015 +0000
@@ -2736,3 +2736,6 @@
 
 compiler.err.garbled.value.reference.instantiation=\
     Mismatched instantiation syntax between value and reference types.
+
+compiler.err.jlo.cannot.declare.supertypes=\
+    The type java.lang.Object cannot have a superclass or superinterfaces
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Wed Dec 02 16:00:08 2015 +0000
@@ -87,6 +87,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;
@@ -108,6 +109,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;
     public final Name java_lang_Value;
 
     // names of builtin classes
@@ -232,6 +234,7 @@
         getMessage = fromString("getMessage");
         hasNext = fromString("hasNext");
         hashCode = fromString("hashCode");
+        identityHashCode = fromString("identityHashCode");
         init = fromString("<init>");
         initCause = fromString("initCause");
         iterator = fromString("iterator");
@@ -254,6 +257,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");
         java_lang_Value = fromString("java.lang.__Value");
 
         // names of builtin classes
--- a/test/tools/javac/Object1.out	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/Object1.out	Wed Dec 02 16:00:08 2015 +0000
@@ -1,2 +1,2 @@
-Object1.java:11:22: compiler.err.cyclic.inheritance: java.lang.Throwable
+Object1.java:11:1: compiler.err.jlo.cannot.declare.supertypes
 1 error
--- a/test/tools/javac/Object2.out	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/Object2.out	Wed Dec 02 16:00:08 2015 +0000
@@ -1,2 +1,2 @@
-Object2.java:11:25: compiler.err.cyclic.inheritance: java.lang.Cloneable
+Object2.java:11:1: compiler.err.jlo.cannot.declare.supertypes
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NoSuperTypesForJLO.java	Wed Dec 02 16:00:08 2015 +0000
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.jlo.cannot.declare.supertypes
+
+package java.lang;
+
+class Object extends Number {
+}
--- a/test/tools/javac/valhalla/values/CheckClone.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckClone.java	Wed Dec 02 16:00:08 2015 +0000
@@ -6,5 +6,11 @@
  */
 
 final __ByValue class CheckClone {
+    final __ByValue class InnerValue {
+        void foo(InnerValue iv) {
+            iv.clone();
+        }
+    }
+    @Override
     protected Object clone() { return null; } // <-- error
 }
--- a/test/tools/javac/valhalla/values/CheckClone.out	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckClone.out	Wed Dec 02 16:00:08 2015 +0000
@@ -1,2 +1,3 @@
-CheckClone.java:9:22: compiler.err.value.does.not.support: clone
-1 error
+CheckClone.java:11:15: compiler.err.value.does.not.support: clone
+CheckClone.java:14:5: compiler.err.method.does.not.override.superclass
+2 errors
--- a/test/tools/javac/valhalla/values/CheckFinalize.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckFinalize.java	Wed Dec 02 16:00:08 2015 +0000
@@ -6,5 +6,13 @@
  */
 
 final __ByValue class CheckFinalize {
+    @Override
     protected void finalize() {} // <-- error
+
+    final __ByValue class CheckFinalizeInner {}
+
+    void foo(CheckFinalizeInner cfi, CheckFinalize cf) {
+        cfi.finalize();          // Error
+        cf.finalize();           // OK.
+    }
 }
--- a/test/tools/javac/valhalla/values/CheckFinalize.out	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckFinalize.out	Wed Dec 02 16:00:08 2015 +0000
@@ -1,2 +1,3 @@
-CheckFinalize.java:9:20: compiler.err.value.does.not.support: finalize
-1 error
+CheckFinalize.java:9:5: compiler.err.method.does.not.override.superclass
+CheckFinalize.java:15:12: compiler.err.value.does.not.support: finalize
+2 errors
--- a/test/tools/javac/valhalla/values/CheckIdentityHash.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckIdentityHash.java	Wed Dec 02 16:00:08 2015 +0000
@@ -13,5 +13,7 @@
         this.identityHashCode(v);      // <- ok
         System.identityHashCode(v);    // <- error
         System.identityHashCode(this); // <- error
+        java.lang.System.identityHashCode(v);    // <- error
+        java.lang.System.identityHashCode(this); // <- error
     }
 }
--- a/test/tools/javac/valhalla/values/CheckIdentityHash.out	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckIdentityHash.out	Wed Dec 02 16:00:08 2015 +0000
@@ -1,3 +1,5 @@
 CheckIdentityHash.java:14:32: compiler.err.value.does.not.support: identityHashCode
 CheckIdentityHash.java:15:32: compiler.err.value.does.not.support: identityHashCode
-2 errors
+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/tools/javac/valhalla/values/CheckIdentityHash01.java	Wed Dec 02 16:00:08 2015 +0000
@@ -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/tools/javac/valhalla/values/CheckIdentityHash01.out	Wed Dec 02 16:00:08 2015 +0000
@@ -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
--- a/test/tools/javac/valhalla/values/CheckSync.java	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckSync.java	Wed Dec 02 16:00:08 2015 +0000
@@ -5,12 +5,38 @@
  * @compile/fail/ref=CheckSync.out -XDrawDiagnostics CheckSync.java
  */
 
-public class CheckSync {
-    final __ByValue class Val { }
+/* 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 = __Make Val();
 
     void test() throws InterruptedException {
-        val.wait(); // <- error
-        val.notify(); // <- error
+        // 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.wait("Hello");
+        val.notify();
+        val.notifyAll();
     }
 }
--- a/test/tools/javac/valhalla/values/CheckSync.out	Tue Nov 24 18:29:55 2015 +0000
+++ b/test/tools/javac/valhalla/values/CheckSync.out	Wed Dec 02 16:00:08 2015 +0000
@@ -1,3 +1,17 @@
-CheckSync.java:13:12: compiler.err.value.does.not.support: wait
-CheckSync.java:14:12: compiler.err.value.does.not.support: notify
-2 errors
+CheckSync.java:18:13: compiler.err.value.does.not.support: wait
+CheckSync.java:19:13: compiler.err.value.does.not.support: wait
+CheckSync.java:20:13: compiler.err.value.does.not.support: wait
+CheckSync.java:21:13: compiler.err.value.does.not.support: notify
+CheckSync.java:22:13: compiler.err.value.does.not.support: notifyAll
+CheckSync.java:23:13: compiler.err.value.does.not.support: finalize
+CheckSync.java:24:13: compiler.err.value.does.not.support: clone
+CheckSync.java:32:12: compiler.err.value.does.not.support: wait
+CheckSync.java:33:12: compiler.err.value.does.not.support: wait
+CheckSync.java:34:12: compiler.err.value.does.not.support: wait
+CheckSync.java:35:12: compiler.err.value.does.not.support: wait
+CheckSync.java:36:12: compiler.err.value.does.not.support: wait
+CheckSync.java:37:12: compiler.err.value.does.not.support: wait
+CheckSync.java:38:12: compiler.err.cant.resolve.location.args: kindname.method, wait, , java.lang.String, (compiler.misc.location.1: kindname.variable, val, CheckSync.Val)
+CheckSync.java:39:12: compiler.err.value.does.not.support: notify
+CheckSync.java:40:12: compiler.err.value.does.not.support: notifyAll
+16 errors