< prev index next >

test/compiler/jvmci/common/CTVMUtilities.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.jvmci.common;
  25 
  26 import java.io.IOException;
  27 import java.lang.reflect.Module;
  28 import java.lang.reflect.Field;
  29 import java.lang.reflect.Executable;
  30 import java.lang.reflect.Constructor;
  31 import java.lang.reflect.Method;
  32 import java.lang.reflect.Modifier;
  33 import java.lang.reflect.Parameter;
  34 import java.util.HashMap;
  35 import java.util.Map;
  36 import java.util.TreeMap;
  37 
  38 import jdk.internal.org.objectweb.asm.ClassReader;
  39 import jdk.internal.org.objectweb.asm.ClassVisitor;
  40 import jdk.internal.org.objectweb.asm.ClassWriter;
  41 import jdk.internal.org.objectweb.asm.Label;
  42 import jdk.internal.org.objectweb.asm.MethodVisitor;
  43 import jdk.internal.org.objectweb.asm.Opcodes;
  44 import jdk.internal.org.objectweb.asm.tree.ClassNode;
  45 import jdk.test.lib.Utils;
  46 import jdk.vm.ci.code.InstalledCode;
  47 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  48 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  49 












  50 public class CTVMUtilities {
  51     /*
  52      * A method to return HotSpotResolvedJavaMethod object using class object
  53      * and method as input
  54      */
  55     public static HotSpotResolvedJavaMethod getResolvedMethod(Class<?> cls,
  56             Executable method) {
  57         if (!(method instanceof Method || method instanceof Constructor)) {
  58             throw new Error("wrong executable type " + method.getClass());
  59         }
  60         Field slotField;
  61         int slot;
  62         try {
  63             slotField = method.getClass().getDeclaredField("slot");
  64             boolean old = slotField.isAccessible();
  65             slotField.setAccessible(true);
  66             slot = slotField.getInt(method);
  67             slotField.setAccessible(old);
  68         } catch (ReflectiveOperationException e) {
  69             throw new Error("TEST BUG: Can't get slot field", e);




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.jvmci.common;
  25 












  26 import jdk.internal.org.objectweb.asm.ClassReader;
  27 import jdk.internal.org.objectweb.asm.ClassVisitor;
  28 import jdk.internal.org.objectweb.asm.ClassWriter;
  29 import jdk.internal.org.objectweb.asm.Label;
  30 import jdk.internal.org.objectweb.asm.MethodVisitor;
  31 import jdk.internal.org.objectweb.asm.Opcodes;
  32 import jdk.internal.org.objectweb.asm.tree.ClassNode;
  33 import jdk.test.lib.Utils;
  34 import jdk.vm.ci.code.InstalledCode;
  35 import jdk.vm.ci.hotspot.CompilerToVMHelper;
  36 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  37 
  38 import java.io.IOException;
  39 import java.lang.reflect.Constructor;
  40 import java.lang.reflect.Executable;
  41 import java.lang.reflect.Field;
  42 import java.lang.reflect.Method;
  43 import java.lang.reflect.Modifier;
  44 import java.lang.reflect.Module;
  45 import java.lang.reflect.Parameter;
  46 import java.util.HashMap;
  47 import java.util.Map;
  48 import java.util.TreeMap;
  49 
  50 public class CTVMUtilities {
  51     /*
  52      * A method to return HotSpotResolvedJavaMethod object using class object
  53      * and method as input
  54      */
  55     public static HotSpotResolvedJavaMethod getResolvedMethod(Class<?> cls,
  56             Executable method) {
  57         if (!(method instanceof Method || method instanceof Constructor)) {
  58             throw new Error("wrong executable type " + method.getClass());
  59         }
  60         Field slotField;
  61         int slot;
  62         try {
  63             slotField = method.getClass().getDeclaredField("slot");
  64             boolean old = slotField.isAccessible();
  65             slotField.setAccessible(true);
  66             slot = slotField.getInt(method);
  67             slotField.setAccessible(old);
  68         } catch (ReflectiveOperationException e) {
  69             throw new Error("TEST BUG: Can't get slot field", e);


< prev index next >