Search in sources :

Example 1 with ModuleVisitor

use of net.bytebuddy.jar.asm.ModuleVisitor in project mockito by mockito.

the class ModuleUtil method moduleInfo.

private static byte[] moduleInfo(boolean isExported, boolean isOpened) {
    ClassWriter classWriter = new ClassWriter(OpenedClassReader.ASM_API);
    classWriter.visit(Opcodes.V9, Opcodes.ACC_MODULE, "module-info", null, null, null);
    ModuleVisitor mv = classWriter.visitModule("mockito.test", 0, null);
    mv.visitRequire("java.base", Opcodes.ACC_MANDATED, null);
    mv.visitPackage("sample");
    if (isExported) {
        mv.visitExport("sample", 0);
    }
    if (isOpened) {
        mv.visitOpen("sample", 0);
    }
    mv.visitEnd();
    classWriter.visitEnd();
    return classWriter.toByteArray();
}
Also used : ModuleVisitor(net.bytebuddy.jar.asm.ModuleVisitor) ClassWriter(net.bytebuddy.jar.asm.ClassWriter)

Aggregations

ClassWriter (net.bytebuddy.jar.asm.ClassWriter)1 ModuleVisitor (net.bytebuddy.jar.asm.ModuleVisitor)1