test/hotspot/jtreg/runtime/JVMDoPrivileged/DoPrivRunAbstract.jasm
author dlong
Wed, 19 Sep 2018 14:47:37 -0700
branchdlong-java-do-priv-branch
changeset 56897 840ad2a9015a
parent 47216 71c04702a3d5
permissions -rw-r--r--
Implement java.security.AccessController.doPrivileged in Java

/*
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * 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
 * @summary Test that JVM_DoPrivilege throws java.lang.AbstractMethodError for an
 *          abstract run() method.
 * @bug 8183962
 * @compile DoPrivRunAbstract.jasm
 * @compile DoPrivRunAbstract$VoidPrivActRunAbstract.jasm
 * @run main DoPrivRunAbstract
 */


// This jasm file was generated from Java code similar to the following, except
// the VoidPrivActRunAbstract interface was removed and changed.  It's now in
// file DoPrivRunAbstract$VoidPrivActRunAbstract.jasm.
//
// public class DoPrivRunAbstract {
//
//    interface VoidPrivActRunAbstract extends PrivilegedAction<Void> {
//        void perform();
//
//        @Override
//        default Void run() {
//            perform();
//            return null;
//        }
//    }
//
//
//    static void doPrivileged(VoidPrivActRunAbstract act) {
//        AccessController.doPrivileged(act);
//    }
//
//    public static void main(String[] args) throws Exception {
//        try {
//            doPrivileged(() -> System.out.println(System.getProperty("java.home")));
//            throw new RuntimeException("Expected AbstractMethodError not throw");
//        } catch (java.lang.AbstractMethodError e) { }
//    }
//}

super public class DoPrivRunAbstract version 51:0 {

    public Method "<init>":"()V" stack 1 locals 1 {
        aload_0;
        invokespecial    Method java/lang/Object."<init>":"()V";
        return;
    }

    static Method doPrivileged:"(LDoPrivRunAbstract$VoidPrivActRunAbstract;)V" stack 1 locals 1 {
        aload_0;
        invokestatic    Method java/security/AccessController.doPrivileged:"(Ljava/security/PrivilegedAction;)Ljava/lang/Object;";
        pop;
        return;
    }

    public static Method main:"([Ljava/lang/String;)V" throws java/lang/Exception stack 3 locals 2 {
        try t0;
        invokedynamic    InvokeDynamic REF_invokeStatic:java/lang/invoke/LambdaMetafactory.metafactory:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;":perform:"()LDoPrivRunAbstract$VoidPrivActRunAbstract;" MethodType "()V", MethodHandle REF_invokeStatic:DoPrivRunAbstract.lambda$main$0:"()V", MethodType "()V";
        invokestatic    Method doPrivileged:"(LDoPrivRunAbstract$VoidPrivActRunAbstract;)V";
        new    class java/lang/RuntimeException;
        dup;
        ldc    String "Expected AbstractMethodError not throw";
        invokespecial    Method java/lang/RuntimeException."<init>":"(Ljava/lang/String;)V";
        athrow;
        endtry t0;
        catch t0 java/lang/AbstractMethodError;
        stack_frame_type stack1;
        stack_map class java/lang/AbstractMethodError;
        astore_1;
        return;
    }

    private static synthetic Method lambda$main$0:"()V" stack 2 locals 0 {
        getstatic    Field java/lang/System.out:"Ljava/io/PrintStream;";
        ldc    String "java.home";
        invokestatic    Method java/lang/System.getProperty:"(Ljava/lang/String;)Ljava/lang/String;";
        invokevirtual    Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
        return;
    }

} // end Class DoPrivRunAbstract