< prev index next >

test/hotspot/jtreg/runtime/verifier/CFLH/TestVerify.java

Print this page
*** 37,11 ***
   * @run main/othervm --patch-module=java.base=. -Dagent.retransform=false -javaagent:redefineagent.jar TestVerify
   * @run main/othervm --patch-module=java.base=. -Dagent.retransform=true -javaagent:redefineagent.jar TestVerify
   */
  
  import java.lang.invoke.MethodHandles;
- import java.time.Duration;
  import java.lang.classfile.ClassFile;
  import java.lang.classfile.ClassTransform;
  import java.lang.classfile.MethodTransform;
  import java.lang.classfile.constantpool.InterfaceMethodRefEntry;
  import java.lang.classfile.instruction.ReturnInstruction;
--- 37,10 ---

*** 59,11 ***
  import jdk.test.lib.helpers.ClassFileInstaller;
  import java.io.FileNotFoundException;
  
  public class TestVerify {
  
!     private static final String CLASS_TO_BREAK = "java.time.Duration";
      private static final String INTERNAL_CLASS_TO_BREAK = CLASS_TO_BREAK.replace('.', '/');
      private static final boolean DEBUG = false;
  
      private static class BadTransformer implements ClassFileTransformer {
  
--- 58,11 ---
  import jdk.test.lib.helpers.ClassFileInstaller;
  import java.io.FileNotFoundException;
  
  public class TestVerify {
  
!     private static final String CLASS_TO_BREAK = "java.util.Date";
      private static final String INTERNAL_CLASS_TO_BREAK = CLASS_TO_BREAK.replace('.', '/');
      private static final boolean DEBUG = false;
  
      private static class BadTransformer implements ClassFileTransformer {
  

*** 89,11 ***
  
                          System.out.println("Done injecting bug");
                      }
                      builder.with(element);
                  });
!                 var classTransform = ClassTransform.transformingMethods(mm -> mm.methodName().stringValue().equals("getSeconds"), methodTransform);
  
                  byte[] bytes;
                  try {
                      var cf = ClassFile.of();
                      var existingClass = cf.parse(classfileBuffer);
--- 88,11 ---
  
                          System.out.println("Done injecting bug");
                      }
                      builder.with(element);
                  });
!                 var classTransform = ClassTransform.transformingMethods(mm -> mm.methodName().stringValue().equals("parse"), methodTransform);
  
                  byte[] bytes;
                  try {
                      var cf = ClassFile.of();
                      var existingClass = cf.parse(classfileBuffer);

*** 162,11 ***
                  inst.addTransformer(new BadTransformer(), true);
                  inst.retransformClasses(clazz);
              } else {
                  // Load the class instrumented with CFLH for the VerifyError.
                  inst.addTransformer(new BadTransformer());
!                 System.out.println("1 hour is " + Duration.ofHours(1).getSeconds() + " seconds");
              }
              throw new RuntimeException("Failed: Did not throw VerifyError");
          } catch (VerifyError e) {
              System.out.println("Passed: VerifyError " + e.getMessage());
          }
--- 161,12 ---
                  inst.addTransformer(new BadTransformer(), true);
                  inst.retransformClasses(clazz);
              } else {
                  // Load the class instrumented with CFLH for the VerifyError.
                  inst.addTransformer(new BadTransformer());
!                 Class<?> cls = Class.forName(CLASS_TO_BREAK);
+                 System.out.println("class loaded" + cls);
              }
              throw new RuntimeException("Failed: Did not throw VerifyError");
          } catch (VerifyError e) {
              System.out.println("Passed: VerifyError " + e.getMessage());
          }
< prev index next >