11/*
2- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2424/*
2525 * @test
2626 * @bug 8256811
27- * @modules java.base/jdk.internal.org.objectweb.asm
28- * java.base/jdk.internal.misc
27+ * @modules java.base/jdk.internal.misc
2928 * @library /test/lib
3029 * @build jdk.test.whitebox.WhiteBox
3130 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
3231 * @run main/othervm/native ClassUnloadEventTest run
3332 */
3433
35- import jdk .internal .org .objectweb .asm .ClassWriter ;
36- import jdk .internal .org .objectweb .asm .Label ;
37- import jdk .internal .org .objectweb .asm .MethodVisitor ;
38- import jdk .internal .org .objectweb .asm .Opcodes ;
3934import jdk .test .lib .classloader .ClassUnloadCommon ;
4035
4136import com .sun .jdi .*;
4540
4641import java .util .*;
4742import java .io .*;
43+ import java .lang .classfile .ClassFile ;
44+ import java .lang .constant .ClassDesc ;
45+ import java .lang .constant .ConstantDescs ;
4846
4947public class ClassUnloadEventTest {
5048 static final String CLASS_NAME_PREFIX = "SampleClass__" ;
@@ -65,18 +63,13 @@ public static void main(String[] args) throws Exception {
6563 }
6664 }
6765
68- private static class TestClassLoader extends ClassLoader implements Opcodes {
66+ private static class TestClassLoader extends ClassLoader {
6967 private static byte [] generateSampleClass (String name ) {
70- ClassWriter cw = new ClassWriter (0 );
71-
72- cw .visit (52 , ACC_SUPER | ACC_PUBLIC , name , null , "java/lang/Object" , null );
73- MethodVisitor mv = cw .visitMethod (ACC_PUBLIC | ACC_STATIC , "m" , "()V" , null , null );
74- mv .visitCode ();
75- mv .visitInsn (RETURN );
76- mv .visitMaxs (0 , 0 );
77- mv .visitEnd ();
78- cw .visitEnd ();
79- return cw .toByteArray ();
68+ return ClassFile .of ().build (ClassDesc .of (name ), clb ->
69+ clb .withVersion (52 , 0 )
70+ .withFlags (ClassFile .ACC_SUPER | ClassFile .ACC_PUBLIC )
71+ .withMethodBody ("m" , ConstantDescs .MTD_void , ClassFile .ACC_PUBLIC | ClassFile .ACC_STATIC , cob ->
72+ cob .return_ ()));
8073 }
8174
8275 @ Override
0 commit comments