test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 47216 71c04702a3d5
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2019, 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.
    26  * @requires vm.jvmci
    26  * @requires vm.jvmci
    27  * @library ../../../../../
    27  * @library ../../../../../
    28  * @modules jdk.internal.vm.ci/jdk.vm.ci.meta
    28  * @modules jdk.internal.vm.ci/jdk.vm.ci.meta
    29  *          jdk.internal.vm.ci/jdk.vm.ci.runtime
    29  *          jdk.internal.vm.ci/jdk.vm.ci.runtime
    30  *          java.base/jdk.internal.misc
    30  *          java.base/jdk.internal.misc
    31  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Djvmci.Compiler=null jdk.vm.ci.runtime.test.TestMetaAccessProvider
    31  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestMetaAccessProvider
    32  */
    32  */
    33 
    33 
    34 package jdk.vm.ci.runtime.test;
    34 package jdk.vm.ci.runtime.test;
    35 
    35 
    36 import jdk.vm.ci.meta.DeoptimizationAction;
    36 import jdk.vm.ci.meta.DeoptimizationAction;
    66                     metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[1]).asInt(),
    66                     metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[1]).asInt(),
    67                     metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[2]).asInt(),
    67                     metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[2]).asInt(),
    68                     metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[3]).asInt()
    68                     metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[3]).asInt()
    69     };
    69     };
    70 
    70 
       
    71     private static boolean isUnsafeAnoymous(ResolvedJavaType type) {
       
    72         return type.getHostClass() != null;
       
    73     }
       
    74 
    71     @Test
    75     @Test
    72     public void lookupJavaTypeTest() {
    76     public void lookupJavaTypeTest() {
    73         for (Class<?> c : classes) {
    77         for (Class<?> c : classes) {
    74             ResolvedJavaType type = metaAccess.lookupJavaType(c);
    78             ResolvedJavaType type = metaAccess.lookupJavaType(c);
    75             assertNotNull(c.toString(), type);
    79             assertNotNull(c.toString(), type);
    76             assertEquals(c.toString(), type.getName(), toInternalName(c.getName()));
    80             if (!isUnsafeAnoymous(type)) {
    77             assertEquals(c.toString(), type.getName(), toInternalName(type.toJavaName()));
    81                 assertEquals(c.toString(), type.getName(), toInternalName(c.getName()));
    78             assertEquals(c.toString(), c.getName(), type.toClassName());
    82                 assertEquals(c.toString(), type.getName(), toInternalName(type.toJavaName()));
    79             if (!type.isArray()) {
    83                 assertEquals(c.toString(), c.getName(), type.toClassName());
    80                 assertEquals(c.toString(), c.getName(), type.toJavaName());
    84                 if (!type.isArray()) {
       
    85                     assertEquals(c.toString(), c.getName(), type.toJavaName());
       
    86                 }
    81             }
    87             }
    82         }
    88         }
    83     }
    89     }
    84 
    90 
    85     @Test(expected = IllegalArgumentException.class)
    91     @Test(expected = IllegalArgumentException.class)
    90     @Test
    96     @Test
    91     public void lookupJavaTypesTest() {
    97     public void lookupJavaTypesTest() {
    92         ResolvedJavaType[] result = metaAccess.lookupJavaTypes(classes.toArray(new Class<?>[classes.size()]));
    98         ResolvedJavaType[] result = metaAccess.lookupJavaTypes(classes.toArray(new Class<?>[classes.size()]));
    93         int counter = 0;
    99         int counter = 0;
    94         for (Class<?> aClass : classes) {
   100         for (Class<?> aClass : classes) {
    95             assertEquals("Unexpected javaType: " + result[counter] + " while expecting of class: " + aClass, result[counter].toClassName(), aClass.getName());
   101             if (!isUnsafeAnoymous(result[counter])) {
       
   102                 assertEquals("Unexpected javaType: " + result[counter] + " while expecting of class: " + aClass, result[counter].toClassName(), aClass.getName());
       
   103             }
    96             counter++;
   104             counter++;
    97         }
   105         }
    98     }
   106     }
    99 
   107 
   100     @Test(expected = NullPointerException.class)
   108     @Test(expected = NullPointerException.class)