< prev index next >

test/hotspot/jtreg/runtime/Nestmates/privateMethods/TestInvokeErrors.java

Print this page




  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 8046171
  27  * @summary Setup nestmate calls to private methods then use
  28  *          modified jcod classes to introduce errors. Test with
  29  *          and without verification enabled
  30  * @compile TestInvokeErrors.java
  31  * @compile MissingMethod.jcod
  32  *          MissingMethodWithSuper.jcod
  33  *          MissingNestTop.jcod
  34  * @run main TestInvokeErrors true
  35  * @run main/othervm -Xverify:none TestInvokeErrors false
  36  */
  37 
  38 public class TestInvokeErrors {
  39 
  40     static class Nested {
  41         private void priv_invoke() {
  42             System.out.println("Nested::priv_invoke");
  43         }
  44     }
  45 
  46     static class MissingMethod {
  47         // jcod version will rename this method to not_priv_invoke
  48         private void priv_invoke() {
  49             System.out.println("MissingMethod::priv_invoke");
  50         }
  51     }
  52 
  53     static class MissingMethodWithSuper extends Nested {
  54         // jcod version will rename this method to not_priv_invoke
  55         private void priv_invoke() {
  56             System.out.println("MissingMethodWithSuper::priv_invoke");
  57         }
  58     }
  59 
  60     static class MissingNestTop {
  61         // jcod version will change MemberOfNest to a non-existent class
  62         private void priv_invoke() {
  63             System.out.println("MissingNestTop::priv_invoke");
  64         }
  65     }
  66 
  67     // Helper class adds a level of indirection to avoid the main class
  68     // failing verification if these tests are written directly in main.
  69     // That can only happen if using invokespecial for nestmate invocation.
  70     static class Helper {
  71         static void doTest() {
  72             try {
  73                 MissingNestTop m = new MissingNestTop();
  74                 m.priv_invoke();
  75                 throw new Error("Unexpected success invoking MissingNestTop.priv_invoke");
  76             }
  77             catch (NoClassDefFoundError ncdfe) {
  78                 System.out.println("Got expected exception:" + ncdfe);
  79             }
  80         }
  81     }
  82 
  83     public static void main(String[] args) throws Throwable {
  84         // some errors change depending on whether they are caught by the
  85         // verifier first
  86         boolean verifying = Boolean.parseBoolean(args[0]);
  87         System.out.println("Verification is " +
  88                            (verifying ? "enabled" : "disabled"));
  89 
  90         try {
  91             MissingMethod m = new MissingMethod();
  92             m.priv_invoke();
  93             throw new Error("Unexpected success invoking MissingMethod.priv_invoke");
  94         }
  95         catch (NoSuchMethodError nsme) {




  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 8046171
  27  * @summary Setup nestmate calls to private methods then use
  28  *          modified jcod classes to introduce errors. Test with
  29  *          and without verification enabled
  30  * @compile TestInvokeErrors.java
  31  * @compile MissingMethod.jcod
  32  *          MissingMethodWithSuper.jcod
  33  *          MissingNestHost.jcod
  34  * @run main TestInvokeErrors true
  35  * @run main/othervm -Xverify:none TestInvokeErrors false
  36  */
  37 
  38 public class TestInvokeErrors {
  39 
  40     static class Nested {
  41         private void priv_invoke() {
  42             System.out.println("Nested::priv_invoke");
  43         }
  44     }
  45 
  46     static class MissingMethod {
  47         // jcod version will rename this method to not_priv_invoke
  48         private void priv_invoke() {
  49             System.out.println("MissingMethod::priv_invoke");
  50         }
  51     }
  52 
  53     static class MissingMethodWithSuper extends Nested {
  54         // jcod version will rename this method to not_priv_invoke
  55         private void priv_invoke() {
  56             System.out.println("MissingMethodWithSuper::priv_invoke");
  57         }
  58     }
  59 
  60     static class MissingNestHost {
  61         // jcod version will change NestHost to a non-existent class
  62         private void priv_invoke() {
  63             System.out.println("MissingNestHost::priv_invoke");
  64         }
  65     }
  66 
  67     // Helper class adds a level of indirection to avoid the main class
  68     // failing verification if these tests are written directly in main.
  69     // That can only happen if using invokespecial for nestmate invocation.
  70     static class Helper {
  71         static void doTest() {
  72             try {
  73                 MissingNestHost m = new MissingNestHost();
  74                 m.priv_invoke();
  75                 throw new Error("Unexpected success invoking MissingNestHost.priv_invoke");
  76             }
  77             catch (NoClassDefFoundError ncdfe) {
  78                 System.out.println("Got expected exception:" + ncdfe);
  79             }
  80         }
  81     }
  82 
  83     public static void main(String[] args) throws Throwable {
  84         // some errors change depending on whether they are caught by the
  85         // verifier first
  86         boolean verifying = Boolean.parseBoolean(args[0]);
  87         System.out.println("Verification is " +
  88                            (verifying ? "enabled" : "disabled"));
  89 
  90         try {
  91             MissingMethod m = new MissingMethod();
  92             m.priv_invoke();
  93             throw new Error("Unexpected success invoking MissingMethod.priv_invoke");
  94         }
  95         catch (NoSuchMethodError nsme) {


< prev index next >