< prev index next >

test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java

Print this page




 654             test_WrongPackageHostPutField();
 655             break;
 656         default:
 657             throw new Error("Uknown mode: " + args[0] +
 658                             ". Must be one of: method, constructor, getField or putField");
 659         }
 660     }
 661 
 662     static void test_GoodInvoke(){
 663         try {
 664             Caller.invokeTarget();
 665         }
 666         catch (Exception e) {
 667             throw new Error("Unexpected exception on good invocation " + e);
 668         }
 669     }
 670 
 671     static void test_NoHostInvoke() throws Throwable {
 672         System.out.println("Testing for missing nest-host attribute");
 673         String msg = "class TestNestmateMembership$Caller tried to access " +
 674             "private method 'void TestNestmateMembership$TargetNoHost.m()'";
 675         try {
 676             Caller.invokeTargetNoHost();
 677             throw new Error("Missing IllegalAccessError: " + msg);
 678         }
 679         catch (IllegalAccessError expected) {
 680             check_expected(expected, msg);
 681         }
 682         msg = "TestNestmateMembership$Caller cannot access a member of class " +
 683             "TestNestmateMembership$TargetNoHost with modifiers \"private static\"";
 684         try {
 685             Caller.invokeTargetNoHostReflectively();
 686             throw new Error("Missing IllegalAccessException: " + msg);
 687         }
 688         catch (IllegalAccessException expected) {
 689             check_expected(expected, msg);
 690         }
 691         msg = "no such method: TestNestmateMembership$TargetNoHost.m()void/invokeStatic";
 692         try {
 693             Caller.invokeTargetNoHostMH();
 694             throw new Error("Missing IllegalAccessException: " + msg);
 695         }
 696         catch (IllegalAccessException expected) {
 697             check_expected(expected, msg);
 698         }
 699 
 700         msg = "class TestNestmateMembership$CallerNoHost tried to access " +
 701             "private method 'void TestNestmateMembership$Target.m()'";
 702         try {
 703             CallerNoHost.invokeTarget();
 704             throw new Error("Missing IllegalAccessError: " + msg);
 705         }
 706         catch (IllegalAccessError expected) {
 707             check_expected(expected, msg);
 708         }
 709         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
 710             "method 'void TestNestmateMembership$TargetNoHost.m()'";
 711         try {
 712             CallerNoHost.invokeTargetNoHost();
 713             throw new Error("Missing IllegalAccessError: " + msg);
 714         }
 715         catch (IllegalAccessError expected) {
 716             check_expected(expected, msg);
 717         }
 718     }
 719 
 720     static void test_SelfHostInvoke() throws Throwable {
 721         System.out.println("Testing for class that lists itself as nest-host");
 722         String msg = "Type TestNestmateMembership$TargetSelfHost (loader: 'app') is not a nest member" +
 723             " of TestNestmateMembership$TargetSelfHost (loader: 'app'): current type is not listed as a nest member";
 724         try {
 725             Caller.invokeTargetSelfHost();
 726             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 727         }
 728         catch (IncompatibleClassChangeError expected) {
 729             check_expected(expected, msg);
 730         }


 933         }
 934         catch (IncompatibleClassChangeError expected) {
 935             check_expected(expected, msg);
 936         }
 937     }
 938 
 939     // constructor tests
 940 
 941    static void test_GoodConstruct(){
 942         try {
 943             Caller.newTarget();
 944         }
 945         catch (Exception e) {
 946             throw new Error("Unexpected exception on good construction: " + e);
 947         }
 948     }
 949 
 950     static void test_NoHostConstruct() throws Throwable {
 951         System.out.println("Testing for missing nest-host attribute");
 952         String msg = "class TestNestmateMembership$Caller tried to access private " +
 953             "method 'void TestNestmateMembership$TargetNoHost.<init>()'";
 954         try {
 955             Caller.newTargetNoHost();
 956             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 957         }
 958         catch (IncompatibleClassChangeError expected) {
 959             check_expected(expected, msg);
 960         }
 961         msg = "class TestNestmateMembership$Caller cannot access a member of class " +
 962             "TestNestmateMembership$TargetNoHost with modifiers \"private\"";
 963         try {
 964             Caller.newTargetNoHostReflectively();
 965             throw new Error("Missing IllegalAccessException: " + msg);
 966         }
 967         catch (IllegalAccessException expected) {
 968             check_expected(expected, msg);
 969         }
 970         msg = "no such constructor: TestNestmateMembership$TargetNoHost.<init>()void/newInvokeSpecial";
 971         try {
 972             Caller.newTargetNoHostMH();
 973             throw new Error("Missing IllegalAccessException: " + msg);
 974         }
 975         catch (IllegalAccessException expected) {
 976             check_expected(expected, msg);
 977         }
 978 
 979         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
 980             "method 'void TestNestmateMembership$Target.<init>()'";
 981         try {
 982             CallerNoHost.newTarget();
 983             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 984         }
 985         catch (IncompatibleClassChangeError expected) {
 986             check_expected(expected, msg);
 987         }
 988         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
 989             "method 'void TestNestmateMembership$TargetNoHost.<init>()'";
 990         try {
 991             CallerNoHost.newTargetNoHost();
 992             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 993         }
 994         catch (IncompatibleClassChangeError expected) {
 995             check_expected(expected, msg);
 996         }
 997     }
 998 
 999     static void test_SelfHostConstruct() throws Throwable {
1000         System.out.println("Testing for class that lists itself as nest-host");
1001         String msg = "Type TestNestmateMembership$TargetSelfHost (loader: 'app') is not a nest member" +
1002             " of TestNestmateMembership$TargetSelfHost (loader: 'app'): current type is not listed as a nest member";
1003         try {
1004             Caller.newTargetSelfHost();
1005             throw new Error("Missing IncompatibleClassChangeError: " + msg);
1006         }
1007         catch (IncompatibleClassChangeError expected) {
1008             check_expected(expected, msg);
1009         }




 654             test_WrongPackageHostPutField();
 655             break;
 656         default:
 657             throw new Error("Uknown mode: " + args[0] +
 658                             ". Must be one of: method, constructor, getField or putField");
 659         }
 660     }
 661 
 662     static void test_GoodInvoke(){
 663         try {
 664             Caller.invokeTarget();
 665         }
 666         catch (Exception e) {
 667             throw new Error("Unexpected exception on good invocation " + e);
 668         }
 669     }
 670 
 671     static void test_NoHostInvoke() throws Throwable {
 672         System.out.println("Testing for missing nest-host attribute");
 673         String msg = "class TestNestmateMembership$Caller tried to access " +
 674             "private method TestNestmateMembership$TargetNoHost.m()V";
 675         try {
 676             Caller.invokeTargetNoHost();
 677             throw new Error("Missing IllegalAccessError: " + msg);
 678         }
 679         catch (IllegalAccessError expected) {
 680             check_expected(expected, msg);
 681         }
 682         msg = "TestNestmateMembership$Caller cannot access a member of class " +
 683             "TestNestmateMembership$TargetNoHost with modifiers \"private static\"";
 684         try {
 685             Caller.invokeTargetNoHostReflectively();
 686             throw new Error("Missing IllegalAccessException: " + msg);
 687         }
 688         catch (IllegalAccessException expected) {
 689             check_expected(expected, msg);
 690         }
 691         msg = "no such method: TestNestmateMembership$TargetNoHost.m()void/invokeStatic";
 692         try {
 693             Caller.invokeTargetNoHostMH();
 694             throw new Error("Missing IllegalAccessException: " + msg);
 695         }
 696         catch (IllegalAccessException expected) {
 697             check_expected(expected, msg);
 698         }
 699 
 700         msg = "class TestNestmateMembership$CallerNoHost tried to access " +
 701             "private method TestNestmateMembership$Target.m()V";
 702         try {
 703             CallerNoHost.invokeTarget();
 704             throw new Error("Missing IllegalAccessError: " + msg);
 705         }
 706         catch (IllegalAccessError expected) {
 707             check_expected(expected, msg);
 708         }
 709         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
 710             "method TestNestmateMembership$TargetNoHost.m()V";
 711         try {
 712             CallerNoHost.invokeTargetNoHost();
 713             throw new Error("Missing IllegalAccessError: " + msg);
 714         }
 715         catch (IllegalAccessError expected) {
 716             check_expected(expected, msg);
 717         }
 718     }
 719 
 720     static void test_SelfHostInvoke() throws Throwable {
 721         System.out.println("Testing for class that lists itself as nest-host");
 722         String msg = "Type TestNestmateMembership$TargetSelfHost (loader: 'app') is not a nest member" +
 723             " of TestNestmateMembership$TargetSelfHost (loader: 'app'): current type is not listed as a nest member";
 724         try {
 725             Caller.invokeTargetSelfHost();
 726             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 727         }
 728         catch (IncompatibleClassChangeError expected) {
 729             check_expected(expected, msg);
 730         }


 933         }
 934         catch (IncompatibleClassChangeError expected) {
 935             check_expected(expected, msg);
 936         }
 937     }
 938 
 939     // constructor tests
 940 
 941    static void test_GoodConstruct(){
 942         try {
 943             Caller.newTarget();
 944         }
 945         catch (Exception e) {
 946             throw new Error("Unexpected exception on good construction: " + e);
 947         }
 948     }
 949 
 950     static void test_NoHostConstruct() throws Throwable {
 951         System.out.println("Testing for missing nest-host attribute");
 952         String msg = "class TestNestmateMembership$Caller tried to access private " +
 953             "method TestNestmateMembership$TargetNoHost.<init>()V";
 954         try {
 955             Caller.newTargetNoHost();
 956             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 957         }
 958         catch (IncompatibleClassChangeError expected) {
 959             check_expected(expected, msg);
 960         }
 961         msg = "class TestNestmateMembership$Caller cannot access a member of class " +
 962             "TestNestmateMembership$TargetNoHost with modifiers \"private\"";
 963         try {
 964             Caller.newTargetNoHostReflectively();
 965             throw new Error("Missing IllegalAccessException: " + msg);
 966         }
 967         catch (IllegalAccessException expected) {
 968             check_expected(expected, msg);
 969         }
 970         msg = "no such constructor: TestNestmateMembership$TargetNoHost.<init>()void/newInvokeSpecial";
 971         try {
 972             Caller.newTargetNoHostMH();
 973             throw new Error("Missing IllegalAccessException: " + msg);
 974         }
 975         catch (IllegalAccessException expected) {
 976             check_expected(expected, msg);
 977         }
 978 
 979         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
 980             "method TestNestmateMembership$Target.<init>()V";
 981         try {
 982             CallerNoHost.newTarget();
 983             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 984         }
 985         catch (IncompatibleClassChangeError expected) {
 986             check_expected(expected, msg);
 987         }
 988         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
 989             "method TestNestmateMembership$TargetNoHost.<init>()V";
 990         try {
 991             CallerNoHost.newTargetNoHost();
 992             throw new Error("Missing IncompatibleClassChangeError: " + msg);
 993         }
 994         catch (IncompatibleClassChangeError expected) {
 995             check_expected(expected, msg);
 996         }
 997     }
 998 
 999     static void test_SelfHostConstruct() throws Throwable {
1000         System.out.println("Testing for class that lists itself as nest-host");
1001         String msg = "Type TestNestmateMembership$TargetSelfHost (loader: 'app') is not a nest member" +
1002             " of TestNestmateMembership$TargetSelfHost (loader: 'app'): current type is not listed as a nest member";
1003         try {
1004             Caller.newTargetSelfHost();
1005             throw new Error("Missing IncompatibleClassChangeError: " + msg);
1006         }
1007         catch (IncompatibleClassChangeError expected) {
1008             check_expected(expected, msg);
1009         }


< prev index next >