/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
/**
* @test
* @bug 6998541
* @summary JSR 292 implement missing return-type conversion for OP_RETYPE_RAW
*
* -XX:+UnlockDiagnosticVMOptions -XX:ScavengeRootsInCode=2
* -DTest6998541.N=100000 -DTest6998541.KIND=cast Test6998541
* -XX:+UnlockDiagnosticVMOptions -XX:ScavengeRootsInCode=2
* -DTest6998541.N=100000 -DTest6998541.KIND=normal Test6998541
*/
public class Test6998541 {
doboolean();
dobyte();
dochar();
doshort();
doint();
dolong();
dofloat();
dodouble();
dovoid();
}
for (int i = 0; i < N; i++) {
boolean2prim(false);
boolean2prim(true);
}
boolean2prim_invalid(true);
}
for (int i = 0; i < N; i++, x++)
byte2prim(x);
}
for (int i = 0; i < N; i++, x++)
char2prim(x);
}
for (int i = 0; i < N; i++, x++)
short2prim(x);
}
for (int i = 0; i < N; i++, x += D) {
int2prim(x);
}
int2prim_invalid(x);
}
for (int i = 0; i < N; i++, x += D)
long2prim(x);
}
for (int i = 0; i < N; i++, x += D)
float2prim(x);
}
for (int i = 0; i < N; i++, x += D)
double2prim(x);
}
for (int i = 0; i < N; i++) {
void2prim(i);
}
// do the other direction here also:
for (int i = 0; i < N; i++) {
prim2void(i);
}
}
}
private static void fail() {
throw new AssertionError();
}
try {
if (DO_CASTS)
try {
} catch (WrongMethodTypeException ex) {
// this was a required WMTE
}
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
byte.class, short.class, int.class, long.class, float.class, double.class
};
if (dst == void.class) return true;
if (src == void.class) return true; // allow void->zero
// primitive conversion works for asType only when it's widening
if (dst == char.class) return false;
}
}
for (int i = 0; i < argc; i++) {
return false;
}
return true;
}
int i = x ? 1 : 0;
if (!DO_CASTS) return;
}
if (DO_CASTS) return;
try { byte y = (byte) mh_bz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> byte
try { char y = (char) mh_cz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> char
try { short y = (short) mh_sz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> short
try { int y = (int) mh_iz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> int
try { long y = (long) mh_jz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> long
try { float y = (float) mh_fz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> float
try { double y = (double) mh_dz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> double
}
if (!DO_CASTS) return;
boolean z = ((x & 1) != 0);
}
if (DO_CASTS) return;
try { char y = (char) mh_cb.invokeExact(x); fail(); } catch (ClassCastException _) {} // byte -> char
try { boolean y = (boolean) mh_zb.invokeExact(x); fail(); } catch (ClassCastException _) {} // byte -> boolean
}
if (!DO_CASTS) return;
boolean z = ((x & 1) != 0);
}
if (DO_CASTS) return;
try { boolean y = (boolean) mh_zc.invokeExact(x); fail(); } catch (ClassCastException _) {} // char -> boolean
try { byte y = (byte) mh_bc.invokeExact(x); fail(); } catch (ClassCastException _) {} // char -> byte
try { short y = (short) mh_sc.invokeExact(x); fail(); } catch (ClassCastException _) {} // char -> short
}
if (!DO_CASTS) return;
boolean z = ((x & 1) != 0);
}
if (DO_CASTS) return;
try { boolean y = (boolean) mh_zs.invokeExact(x); fail(); } catch (ClassCastException _) {} // short -> boolean
try { byte y = (byte) mh_bs.invokeExact(x); fail(); } catch (ClassCastException _) {} // short -> byte
try { char y = (char) mh_cs.invokeExact(x); fail(); } catch (ClassCastException _) {} // short -> char
}
if (!DO_CASTS) return;
boolean z = ((x & 1) != 0);
}
if (DO_CASTS) return;
try { boolean y = (boolean) mh_zi.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> boolean
try { byte y = (byte) mh_bi.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> byte
try { char y = (char) mh_ci.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> char
try { short y = (short) mh_si.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> short
}
if (!DO_CASTS) return;
boolean z = ((x & 1) != 0);
}
if (DO_CASTS) return;
try { boolean y = (boolean) mh_zj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> boolean
try { byte y = (byte) mh_bj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> byte
try { char y = (char) mh_cj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> char
try { short y = (short) mh_sj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> short
}
if (!DO_CASTS) return;
boolean z = (((byte) x & 1) != 0);
}
if (DO_CASTS) return;
try { boolean y = (boolean) mh_zf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> boolean
try { byte y = (byte) mh_bf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> byte
try { char y = (char) mh_cf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> char
try { short y = (short) mh_sf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> short
try { long y = (long) mh_jf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> long
}
if (!DO_CASTS) return;
boolean z = (((byte) x & 1) != 0);
}
if (DO_CASTS) return;
try { boolean y = (boolean) mh_zd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> boolean
try { byte y = (byte) mh_bd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> byte
try { char y = (char) mh_cd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> char
try { short y = (short) mh_sd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> short
try { int y = (int) mh_id.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> int
try { long y = (long) mh_jd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> long
try { float y = (float) mh_fd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> float
}
}
// no cases
}
boolean z = ((x & 1) != 0);
}
// no cases
}
private static boolean identity(boolean v) { return v; }
private static byte identity(byte v) { return v; }
private static char identity(char v) { return v; }
private static short identity(short v) { return v; }
private static int identity(int v) { return v; }
private static long identity(long v) { return v; }
private static float identity(float v) { return v; }
private static double identity(double v) { return v; }
private static void identity() {}
}