comparison test/compiler/6987555/Test6987555.java @ 2253:62a8557e8f36

7018277: JSR 292 change test/compiler/6987555/Test6987555.java to new MH syntax Summary: test/compiler/6987555/Test6987555.java currently does not compile because the MH return-type syntax has changed. Reviewed-by: never
author twisti
date Thu, 10 Feb 2011 00:47:59 -0800
parents 5beba6174298
children
comparison
equal deleted inserted replaced
2252:72d6c57d0658 2253:62a8557e8f36
1 /* 1 /*
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
52 } 52 }
53 static void doboolean(boolean x) throws Throwable { 53 static void doboolean(boolean x) throws Throwable {
54 if (DEBUG) System.out.println("boolean=" + x); 54 if (DEBUG) System.out.println("boolean=" + x);
55 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class)); 55 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class));
56 MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class)); 56 MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class));
57 boolean a = mh1.<boolean>invokeExact(x); 57 boolean a = (boolean) mh1.invokeExact(x);
58 boolean b = mh2.<boolean>invokeExact(Boolean.valueOf(x)); 58 boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x));
59 assert a == b : a + " != " + b; 59 assert a == b : a + " != " + b;
60 } 60 }
61 61
62 // byte 62 // byte
63 static void testbyte() throws Throwable { 63 static void testbyte() throws Throwable {
78 } 78 }
79 static void dobyte(byte x) throws Throwable { 79 static void dobyte(byte x) throws Throwable {
80 if (DEBUG) System.out.println("byte=" + x); 80 if (DEBUG) System.out.println("byte=" + x);
81 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class)); 81 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class));
82 MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class)); 82 MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class));
83 byte a = mh1.<byte>invokeExact(x); 83 byte a = (byte) mh1.invokeExact(x);
84 byte b = mh2.<byte>invokeExact(Byte.valueOf(x)); 84 byte b = (byte) mh2.invokeExact(Byte.valueOf(x));
85 assert a == b : a + " != " + b; 85 assert a == b : a + " != " + b;
86 } 86 }
87 87
88 // char 88 // char
89 static void testchar() throws Throwable { 89 static void testchar() throws Throwable {
102 } 102 }
103 static void dochar(char x) throws Throwable { 103 static void dochar(char x) throws Throwable {
104 if (DEBUG) System.out.println("char=" + x); 104 if (DEBUG) System.out.println("char=" + x);
105 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class)); 105 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class));
106 MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class)); 106 MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class));
107 char a = mh1.<char>invokeExact(x); 107 char a = (char) mh1.invokeExact(x);
108 char b = mh2.<char>invokeExact(Character.valueOf(x)); 108 char b = (char) mh2.invokeExact(Character.valueOf(x));
109 assert a == b : a + " != " + b; 109 assert a == b : a + " != " + b;
110 } 110 }
111 111
112 // short 112 // short
113 static void testshort() throws Throwable { 113 static void testshort() throws Throwable {
132 } 132 }
133 static void doshort(short x) throws Throwable { 133 static void doshort(short x) throws Throwable {
134 if (DEBUG) System.out.println("short=" + x); 134 if (DEBUG) System.out.println("short=" + x);
135 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class)); 135 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class));
136 MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class)); 136 MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class));
137 short a = mh1.<short>invokeExact(x); 137 short a = (short) mh1.invokeExact(x);
138 short b = mh2.<short>invokeExact(Short.valueOf(x)); 138 short b = (short) mh2.invokeExact(Short.valueOf(x));
139 assert a == b : a + " != " + b; 139 assert a == b : a + " != " + b;
140 } 140 }
141 141
142 // int 142 // int
143 static void testint() throws Throwable { 143 static void testint() throws Throwable {
162 } 162 }
163 static void doint(int x) throws Throwable { 163 static void doint(int x) throws Throwable {
164 if (DEBUG) System.out.println("int=" + x); 164 if (DEBUG) System.out.println("int=" + x);
165 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class)); 165 MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class));
166 MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class)); 166 MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class));
167 int a = mh1.<int>invokeExact(x); 167 int a = (int) mh1.invokeExact(x);
168 int b = mh2.<int>invokeExact(Integer.valueOf(x)); 168 int b = (int) mh2.invokeExact(Integer.valueOf(x));
169 assert a == b : a + " != " + b; 169 assert a == b : a + " != " + b;
170 } 170 }
171 171
172 public static boolean foo(boolean i) { return i; } 172 public static boolean foo(boolean i) { return i; }
173 public static byte foo(byte i) { return i; } 173 public static byte foo(byte i) { return i; }