1 /*
 2  * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.  Oracle designates this
 8  * particular file as subject to the "Classpath" exception as provided
 9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package java.lang;
27 
28 /**
29  * A restricted interface implemented by all primitive objects.
30  *
31  * A primitive object is an instance of a primitive class, lacking identity.
32  *
33  * Every object is either an *identity object* or a *primitive object*. Identity
34  * objects have a unique identity determined for them at instance creation time and
35  * preserved throughout their life.
36  *
37  * Primitive objects do *not* have an identity. Instead, they simply aggregate a
38  * set of immutable field values. The lack of identity enables certain performance
39  * optimizations by Java Virtual Machine implementations.
40  * The following operations have special behavior when applied to primitive
41  * objects:
42  *
43  * - The `==` operator, and the default implementation of the `Object.equals`
44  * method, compare the values of the operands' fields. Primitive objects
45  * created at different points in a program may be `==`.
46  *
47  * - The `System.identityHashCode` method, and the default implementation of the
48  * `Object.hashCode` method, generate a hash code from the hash codes of a
49  * primitive object's fields.
50  *
51  * - The `synchronized` modifier and `synchronized` statement always fail when
52  * applied to a primitive object.
53  *
54  * A class may implement `PrimitiveObject` or `IdentityObject`, but never both.
55  * Primitive classes always implement `PrimitiveObject`, while all other concrete
56  * classes (except `Object`) implicitly implement `IdentityObject`.
57  *
58  * Abstract classes and interfaces may implement or extend this interface if they
59  * wish to guarantee that all instances of the class or interface are primitive
60  * objects.
61  *
62  * @since 1.16
63  */
64 
65 public interface PrimitiveObject {
66 }