Print this page


Split Close
Expand all
Collapse all
          --- old/test/compiler/6987555/Test6987555.java
          +++ new/test/compiler/6987555/Test6987555.java
   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    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 34 lines elided ↑ open up ↑
  47   47  
  48   48      // boolean
  49   49      static void testboolean() throws Throwable {
  50   50          doboolean(false);
  51   51          doboolean(true);
  52   52      }
  53   53      static void doboolean(boolean x) throws Throwable {
  54   54          if (DEBUG)  System.out.println("boolean=" + x);
  55   55          MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class));
  56   56          MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class));
  57      -        boolean a = mh1.<boolean>invokeExact(x);
  58      -        boolean b = mh2.<boolean>invokeExact(Boolean.valueOf(x));
       57 +        boolean a = (boolean) mh1.invokeExact(x);
       58 +        boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x));
  59   59          assert a == b : a + " != " + b;
  60   60      }
  61   61  
  62   62      // byte
  63   63      static void testbyte() throws Throwable {
  64   64          byte[] a = new byte[] {
  65   65              Byte.MIN_VALUE,
  66   66              Byte.MIN_VALUE + 1,
  67   67              -0x0F,
  68   68              -1,
↓ open down ↓ 4 lines elided ↑ open up ↑
  73   73              Byte.MAX_VALUE
  74   74          };
  75   75          for (int i = 0; i < a.length; i++) {
  76   76              dobyte(a[i]);
  77   77          }
  78   78      }
  79   79      static void dobyte(byte x) throws Throwable {
  80   80          if (DEBUG)  System.out.println("byte=" + x);
  81   81          MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class));
  82   82          MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class));
  83      -        byte a = mh1.<byte>invokeExact(x);
  84      -        byte b = mh2.<byte>invokeExact(Byte.valueOf(x));
       83 +        byte a = (byte) mh1.invokeExact(x);
       84 +        byte b = (byte) mh2.invokeExact(Byte.valueOf(x));
  85   85          assert a == b : a + " != " + b;
  86   86      }
  87   87  
  88   88      // char
  89   89      static void testchar() throws Throwable {
  90   90          char[] a = new char[] {
  91   91              Character.MIN_VALUE,
  92   92              Character.MIN_VALUE + 1,
  93   93              0x000F,
  94   94              0x00FF,
↓ open down ↓ 2 lines elided ↑ open up ↑
  97   97              Character.MAX_VALUE
  98   98          };
  99   99          for (int i = 0; i < a.length; i++) {
 100  100              dochar(a[i]);
 101  101          }
 102  102      }
 103  103      static void dochar(char x) throws Throwable {
 104  104          if (DEBUG)  System.out.println("char=" + x);
 105  105          MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class));
 106  106          MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class));
 107      -        char a = mh1.<char>invokeExact(x);
 108      -        char b = mh2.<char>invokeExact(Character.valueOf(x));
      107 +        char a = (char) mh1.invokeExact(x);
      108 +        char b = (char) mh2.invokeExact(Character.valueOf(x));
 109  109          assert a == b : a + " != " + b;
 110  110      }
 111  111  
 112  112      // short
 113  113      static void testshort() throws Throwable {
 114  114          short[] a = new short[] {
 115  115              Short.MIN_VALUE,
 116  116              Short.MIN_VALUE + 1,
 117  117              -0x0FFF,
 118  118              -0x00FF,
↓ open down ↓ 8 lines elided ↑ open up ↑
 127  127              Short.MAX_VALUE
 128  128          };
 129  129          for (int i = 0; i < a.length; i++) {
 130  130              doshort(a[i]);
 131  131          }
 132  132      }
 133  133      static void doshort(short x) throws Throwable {
 134  134          if (DEBUG)  System.out.println("short=" + x);
 135  135          MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class));
 136  136          MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class));
 137      -        short a = mh1.<short>invokeExact(x);
 138      -        short b = mh2.<short>invokeExact(Short.valueOf(x));
      137 +        short a = (short) mh1.invokeExact(x);
      138 +        short b = (short) mh2.invokeExact(Short.valueOf(x));
 139  139          assert a == b : a + " != " + b;
 140  140      }
 141  141  
 142  142      // int
 143  143      static void testint() throws Throwable {
 144  144          int[] a = new int[] {
 145  145              Integer.MIN_VALUE,
 146  146              Integer.MIN_VALUE + 1,
 147  147              -0x00000FFF,
 148  148              -0x000000FF,
↓ open down ↓ 8 lines elided ↑ open up ↑
 157  157              Integer.MAX_VALUE
 158  158          };
 159  159          for (int i = 0; i < a.length; i++) {
 160  160              doint(a[i]);
 161  161          }
 162  162      }
 163  163      static void doint(int x) throws Throwable {
 164  164          if (DEBUG)  System.out.println("int=" + x);
 165  165          MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class));
 166  166          MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class));
 167      -        int a = mh1.<int>invokeExact(x);
 168      -        int b = mh2.<int>invokeExact(Integer.valueOf(x));
      167 +        int a = (int) mh1.invokeExact(x);
      168 +        int b = (int) mh2.invokeExact(Integer.valueOf(x));
 169  169          assert a == b : a + " != " + b;
 170  170      }
 171  171  
 172  172      public static boolean foo(boolean i) { return i; }
 173  173      public static byte    foo(byte    i) { return i; }
 174  174      public static char    foo(char    i) { return i; }
 175  175      public static short   foo(short   i) { return i; }
 176  176      public static int     foo(int     i) { return i; }
 177  177  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX