hotspot/test/compiler/8015436/Test8015436.java
author sspitsyn
Tue, 04 Jun 2013 01:06:50 -0700
changeset 17865 0052c3c499ed
parent 17859 cda7f55ca4dc
permissions -rw-r--r--
8015803: Test8015436.java fails 'can not access a member of class Test8015436 with modifiers "public static"' Summary: Newly added test has an issue: the main class must be public Reviewed-by: kvn, jbachorik, coleenp Contributed-by: serguei.spitsyn@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17859
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     1
/*
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     4
 *
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     8
 *
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    13
 * accompanied this code).
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    14
 *
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    18
 *
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    21
 * questions.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    22
 */
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    23
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    24
/*
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    25
 * @test
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    26
 * @bug 8015436
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    27
 * @summary the IK _initial_method_idnum value must be adjusted if overpass methods are added
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    28
 * @run main Test8015436
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    29
 *
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    30
 */
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    31
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    32
/*
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    33
 * The test checks that a MemberName for the defaultMethod() is cached in
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    34
 * the class MemberNameTable without a crash in the VM fastdebug mode.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    35
 * The original issue was that the InstanceKlass _initial_method_idnum was
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    36
 * not adjusted properly when the overpass methods are added to the class.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    37
 * The expected/correct behavior: The test does not crash nor throw any exceptions.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    38
 * All the invocations of the defaultMethod() must be completed successfully.
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    39
 */
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    40
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    41
import java.lang.invoke.*;
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    42
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    43
interface InterfaceWithDefaultMethod {
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    44
    public void someMethod();
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    45
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    46
    default public void defaultMethod(String str){
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    47
        System.out.println("defaultMethod() " + str);
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    48
    }
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    49
}
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    50
17865
0052c3c499ed 8015803: Test8015436.java fails 'can not access a member of class Test8015436 with modifiers "public static"'
sspitsyn
parents: 17859
diff changeset
    51
public class Test8015436 implements InterfaceWithDefaultMethod {
17859
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    52
    @Override
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    53
    public void someMethod() {
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    54
        System.out.println("someMethod() invoked");
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    55
    }
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    56
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    57
    public static void main(String[] args) throws Throwable {
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    58
        Test8015436 testObj = new Test8015436();
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    59
        testObj.someMethod();
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    60
        testObj.defaultMethod("invoked directly");
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    61
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    62
        MethodHandles.Lookup lookup = MethodHandles.lookup();
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    63
        MethodType   mt = MethodType.methodType(void.class, String.class);
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    64
        MethodHandle mh = lookup.findVirtual(Test8015436.class, "defaultMethod", mt);
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    65
        mh.invokeExact(testObj, "invoked via a MethodHandle");
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    66
    }
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    67
}
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    68
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    69
/*
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    70
 * A successful execution gives the output:
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    71
 *   someMethod() invoked
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    72
 *   defaultMethod() invoked directly
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    73
 *   defaultMethod() invoked via a MethodHandle
cda7f55ca4dc 8015436: compiler/ciReplay/TestSA.sh fails with assert() index is out of bounds
sspitsyn
parents:
diff changeset
    74
 */