changeset 49152:7b9fcae23a16

8196920: VerifierTest_1A.java and VerifierTest_1B.java fail: assert(receiver_klass->is_subtype_of(static_receiver_klass)) failed: actual receiver must be subclass of static receiver klass Summary: add an unverifiable method to the test class Reviewed-by: dholmes, iklam
author ccheung
date Wed, 14 Feb 2018 10:32:19 -0800
parents e9b007212236
children 66173ef5fbbf
files test/hotspot/jtreg/runtime/appcds/VerifierTest.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/runtime/appcds/VerifierTest.java	Wed Feb 14 06:57:28 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/VerifierTest.java	Wed Feb 14 10:32:19 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, 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
@@ -279,7 +279,7 @@
         MethodVisitor mv;
         AnnotationVisitor av0;
 
-        cw.visit(V1_6, ACC_SUPER, "UnverifiableBase", null, "java/lang/Object", null);
+        cw.visit(V1_8, ACC_SUPER, "UnverifiableBase", null, "java/lang/Object", null);
         {
             fv = cw.visitField(ACC_FINAL + ACC_STATIC, "x", "LVerifierTest;", null, null);
             fv.visitEnd();
@@ -296,8 +296,7 @@
         {
             mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
             mv.visitCode();
-            //WAS mv.visitTypeInsn(NEW, "VerifierTest");
-            mv.visitTypeInsn(NEW, "java/lang/Object");
+            mv.visitTypeInsn(NEW, "VerifierTest0");
             mv.visitInsn(DUP);
             mv.visitMethodInsn(INVOKESPECIAL, "VerifierTest0", "<init>", "()V", false);
             mv.visitFieldInsn(PUTSTATIC, "UnverifiableBase", "x", "LVerifierTest;");
@@ -305,6 +304,7 @@
             mv.visitMaxs(2, 0);
             mv.visitEnd();
         }
+        addBadMethod(cw);
         cw.visitEnd();
 
         return cw.toByteArray();
@@ -317,7 +317,7 @@
         MethodVisitor mv;
         AnnotationVisitor av0;
 
-        cw.visit(V1_6, ACC_ABSTRACT + ACC_INTERFACE, "UnverifiableIntf", null, "java/lang/Object", null);
+        cw.visit(V1_8, ACC_ABSTRACT + ACC_INTERFACE, "UnverifiableIntf", null, "java/lang/Object", null);
 
         {
             fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "x", "LVerifierTest0;", null, null);
@@ -326,8 +326,7 @@
         {
             mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
             mv.visitCode();
-            //WAS mv.visitTypeInsn(NEW, "VerifierTest");
-            mv.visitTypeInsn(NEW, "java/lang/Object");
+            mv.visitTypeInsn(NEW, "VerifierTest0");
             mv.visitInsn(DUP);
             mv.visitMethodInsn(INVOKESPECIAL, "VerifierTest0", "<init>", "()V", false);
             mv.visitFieldInsn(PUTSTATIC, "UnverifiableIntf", "x", "LVerifierTest0;");
@@ -335,9 +334,18 @@
             mv.visitMaxs(2, 0);
             mv.visitEnd();
         }
+        addBadMethod(cw);
         cw.visitEnd();
 
         return cw.toByteArray();
     }
 
+    // Add a bad method to make the class fail verification.
+    static void addBadMethod(ClassWriter cw) throws Exception {
+        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "bad", "()V", null, null);
+        mv.visitCode();
+        mv.visitInsn(ARETURN); //  java.lang.VerifyError: Operand stack underflow
+        mv.visitMaxs(2, 2);
+        mv.visitEnd();
+    }
 }