< prev index next >

test/compiler/jsr292/MHInlineTest.java

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


   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 /**
  25  * @test
  26  * @bug 8062280
  27  * @summary C2: inlining failure due to access checks being too strict
  28  * @modules java.base/jdk.internal.misc
  29  * @library /testlibrary
  30  * @run main/othervm MHInlineTest

  31  */
  32 import java.lang.invoke.*;
  33 import jdk.test.lib.*;
  34 import static jdk.test.lib.Asserts.*;
  35 











  36 public class MHInlineTest {
  37     public static void main(String[] args) throws Exception {
  38         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  39                 "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
  40                 "-server", "-XX:-TieredCompilation", "-Xbatch",
  41                 "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining",
  42                 "-XX:CompileCommand=dontinline,MHInlineTest::test*",
  43                     "MHInlineTest$Launcher");
  44 
  45         OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
  46 
  47         analyzer.shouldHaveExitValue(0);
  48 
  49         // The test is applicable only to C2 (present in Server VM).
  50         if (analyzer.getStderr().contains("Server VM")) {
  51             analyzer.shouldContain("MHInlineTest$B::public_x (3 bytes)   inline (hot)");
  52             analyzer.shouldContain("MHInlineTest$B::protected_x (3 bytes)   inline (hot)");
  53             analyzer.shouldContain("MHInlineTest$B::package_x (3 bytes)   inline (hot)");
  54             analyzer.shouldContain("MHInlineTest$A::package_final_x (3 bytes)   inline (hot)");
  55             analyzer.shouldContain("MHInlineTest$B::private_x (3 bytes)   inline (hot)");
  56             analyzer.shouldContain("MHInlineTest$B::private_static_x (3 bytes)   inline (hot)");
  57             analyzer.shouldContain("MHInlineTest$A::package_static_x (3 bytes)   inline (hot)");
  58         }
  59     }
  60 
  61     static class A {
  62         public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
  63 
  64         public Class<?>         public_x() { return A.class; }
  65         protected Class<?>   protected_x() { return A.class; }
  66         Class<?>               package_x() { return A.class; }
  67         final Class<?>   package_final_x() { return A.class; }
  68 
  69         static Class<?> package_static_x() { return A.class; }
  70     }
  71 
  72     static class B extends A {
  73         public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
  74 
  75         @Override public    Class<?>    public_x() { return B.class; }
  76         @Override protected Class<?> protected_x() { return B.class; }
  77         @Override Class<?>             package_x() { return B.class; }




   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 /**
  25  * @test
  26  * @bug 8062280
  27  * @summary C2: inlining failure due to access checks being too strict
  28  * @modules java.base/jdk.internal.misc
  29  * @library /testlibrary /
  30  *
  31  * @run main/othervm compiler.jsr292.MHInlineTest
  32  */



  33 
  34 package compiler.jsr292;
  35 
  36 import jdk.test.lib.OutputAnalyzer;
  37 import jdk.test.lib.ProcessTools;
  38 
  39 import java.lang.invoke.MethodHandle;
  40 import java.lang.invoke.MethodHandles;
  41 import java.lang.invoke.MethodType;
  42 
  43 import static jdk.test.lib.Asserts.assertEquals;
  44 
  45 public class MHInlineTest {
  46     public static void main(String[] args) throws Exception {
  47         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  48                 "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
  49                 "-server", "-XX:-TieredCompilation", "-Xbatch",
  50                 "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining",
  51                 "-XX:CompileCommand=dontinline,compiler.jsr292.MHInlineTest::test*",
  52                     Launcher.class.getName());
  53 
  54         OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
  55 
  56         analyzer.shouldHaveExitValue(0);
  57 
  58         // The test is applicable only to C2 (present in Server VM).
  59         if (analyzer.getStderr().contains("Server VM")) {
  60             analyzer.shouldContain("compiler.jsr292.MHInlineTest$B::public_x (3 bytes)   inline (hot)");
  61             analyzer.shouldContain("compiler.jsr292.MHInlineTest$B::protected_x (3 bytes)   inline (hot)");
  62             analyzer.shouldContain("compiler.jsr292.MHInlineTest$B::package_x (3 bytes)   inline (hot)");
  63             analyzer.shouldContain("compiler.jsr292.MHInlineTest$A::package_final_x (3 bytes)   inline (hot)");
  64             analyzer.shouldContain("compiler.jsr292.MHInlineTest$B::private_x (3 bytes)   inline (hot)");
  65             analyzer.shouldContain("compiler.jsr292.MHInlineTest$B::private_static_x (3 bytes)   inline (hot)");
  66             analyzer.shouldContain("compiler.jsr292.MHInlineTest$A::package_static_x (3 bytes)   inline (hot)");
  67         }
  68     }
  69 
  70     static class A {
  71         public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
  72 
  73         public Class<?>         public_x() { return A.class; }
  74         protected Class<?>   protected_x() { return A.class; }
  75         Class<?>               package_x() { return A.class; }
  76         final Class<?>   package_final_x() { return A.class; }
  77 
  78         static Class<?> package_static_x() { return A.class; }
  79     }
  80 
  81     static class B extends A {
  82         public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
  83 
  84         @Override public    Class<?>    public_x() { return B.class; }
  85         @Override protected Class<?> protected_x() { return B.class; }
  86         @Override Class<?>             package_x() { return B.class; }


< prev index next >