< prev index next > src/java.base/share/classes/java/lang/IdentityObject.java
Print this page
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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
package java.lang;
/**
* A restricted interface implemented by all identity objects.
- * @since 1.14
+ * @since Valhalla
*/
public interface IdentityObject {
+ /**
+ * Returns a new Object implementing the {@code IdentityObject} interface.
+ * The object is a unique {@link IdentityObject} suitable for all purposes
+ * for which {@code new Object{}} was used including synchronization,
+ * mutexes and unique placeholders.
+ *
+ * @return a new Object implementing the IdentityObject interface
+ * @since Valhalla
+ */
+ static IdentityObject newIdentity() {
+ // Return a new instance of an anonymous inner class.
+ return new IdentityObject() { };
+ }
}
< prev index next >