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 sun.invoke.util;
27
28 public enum Wrapper {
29 BOOLEAN(Boolean.class, boolean.class, 'Z', (Boolean)false, new boolean[0], Format.unsigned(1)),
30 // These must be in the order defined for widening primitive conversions in JLS 5.1.2
31 BYTE(Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed(8)),
32 SHORT(Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed(16)),
33 CHAR(Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)),
34 INT(Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed(32)),
35 LONG(Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed(64)),
36 FLOAT(Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)),
37 DOUBLE(Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)),
38 //NULL(Null.class, null.class, 'N', null, null, Format.other(1)),
39 OBJECT(Object.class, Object.class, 'L', null, new Object[0], Format.other(1)),
40 // VOID must be the last type, since it is "assignable" from any other type:
41 VOID(Void.class, void.class, 'V', null, null, Format.other(0)),
42 ;
43
44 private final Class<?> wrapperType;
45 private final Class<?> primitiveType;
46 private final char basicTypeChar;
47 private final Object zero;
48 private final Object emptyArray;
49 private final int format;
50 private final String wrapperSimpleName;
51 private final String primitiveSimpleName;
52
53 private Wrapper(Class<?> wtype, Class<?> ptype, char tchar, Object zero, Object emptyArray, int format) {
54 this.wrapperType = wtype;
55 this.primitiveType = ptype;
56 this.basicTypeChar = tchar;
57 this.zero = zero;
58 this.emptyArray = emptyArray;
59 this.format = format;
60 this.wrapperSimpleName = wtype.getSimpleName();
61 this.primitiveSimpleName = ptype.getSimpleName();
|
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 sun.invoke.util;
27
28 public enum Wrapper {
29 // wrapperType primitiveType char zero emptyArray format
30 BOOLEAN( Boolean.class, boolean.class, 'Z', (Boolean)false, new boolean[0], Format.unsigned( 1)),
31 // These must be in the order defined for widening primitive conversions in JLS 5.1.2
32 BYTE ( Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed( 8)),
33 SHORT ( Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed( 16)),
34 CHAR (Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)),
35 INT ( Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed( 32)),
36 LONG ( Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed( 64)),
37 FLOAT ( Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)),
38 DOUBLE ( Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)),
39 OBJECT ( Object.class, Object.class, 'L', null, new Object[0], Format.other( 1)),
40 // VOID must be the last type, since it is "assignable" from any other type:
41 VOID ( Void.class, void.class, 'V', null, null, Format.other( 0)),
42 ;
43
44 private final Class<?> wrapperType;
45 private final Class<?> primitiveType;
46 private final char basicTypeChar;
47 private final Object zero;
48 private final Object emptyArray;
49 private final int format;
50 private final String wrapperSimpleName;
51 private final String primitiveSimpleName;
52
53 private Wrapper(Class<?> wtype, Class<?> ptype, char tchar, Object zero, Object emptyArray, int format) {
54 this.wrapperType = wtype;
55 this.primitiveType = ptype;
56 this.basicTypeChar = tchar;
57 this.zero = zero;
58 this.emptyArray = emptyArray;
59 this.format = format;
60 this.wrapperSimpleName = wtype.getSimpleName();
61 this.primitiveSimpleName = ptype.getSimpleName();
|