Java Code Examples for org.objectweb.asm.ModuleVisitor#visitRequire()

The following examples show how to use org.objectweb.asm.ModuleVisitor#visitRequire() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassWriterTest.java    From turbine with Apache License 2.0 5 votes vote down vote up
@Test
public void module() throws Exception {

  org.objectweb.asm.ClassWriter cw = new org.objectweb.asm.ClassWriter(0);

  cw.visit(53, /* access= */ 53, "module-info", null, null, null);

  ModuleVisitor mv = cw.visitModule("mod", Opcodes.ACC_OPEN, "mod-ver");

  mv.visitRequire("r1", Opcodes.ACC_TRANSITIVE, "r1-ver");
  mv.visitRequire("r2", Opcodes.ACC_STATIC_PHASE, "r2-ver");
  mv.visitRequire("r3", Opcodes.ACC_STATIC_PHASE | Opcodes.ACC_TRANSITIVE, "r3-ver");

  mv.visitExport("e1", Opcodes.ACC_SYNTHETIC, "e1m1", "e1m2", "e1m3");
  mv.visitExport("e2", Opcodes.ACC_MANDATED, "e2m1", "e2m2");
  mv.visitExport("e3", /* access= */ 0, "e3m1");

  mv.visitOpen("o1", Opcodes.ACC_SYNTHETIC, "o1m1", "o1m2", "o1m3");
  mv.visitOpen("o2", Opcodes.ACC_MANDATED, "o2m1", "o2m2");
  mv.visitOpen("o3", /* access= */ 0, "o3m1");

  mv.visitUse("u1");
  mv.visitUse("u2");
  mv.visitUse("u3");
  mv.visitUse("u4");

  mv.visitProvide("p1", "p1i1", "p1i2");
  mv.visitProvide("p2", "p2i1", "p2i2", "p2i3");

  byte[] inputBytes = cw.toByteArray();
  byte[] outputBytes = ClassWriter.writeClass(ClassReader.read("module-info", inputBytes));

  assertThat(AsmUtils.textify(inputBytes, /* skipDebug= */ true))
      .isEqualTo(AsmUtils.textify(outputBytes, /* skipDebug= */ true));

  // test a round trip
  outputBytes = ClassWriter.writeClass(ClassReader.read("module-info", outputBytes));
  assertThat(AsmUtils.textify(inputBytes, /* skipDebug= */ true))
      .isEqualTo(AsmUtils.textify(outputBytes, /* skipDebug= */ true));
}
 
Example 2
Source File: ModuleInfoGenerator.java    From JOML with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    File dest = new File(args[0]);
    ClassWriter cw = new ClassWriter(0);
    cw.visit(V9, Opcodes.ACC_MODULE, "module-info", null, null, null);
    ModuleVisitor mv = cw.visitModule("org.joml", 0, args[1]);
    mv.visitRequire("java.base", ACC_MANDATED, "9");
    mv.visitRequire("jdk.unsupported", ACC_STATIC_PHASE, null);
    mv.visitExport("org/joml", 0, (String[]) null);
    mv.visitExport("org/joml/sampling", 0, (String[]) null);
    mv.visitEnd();
    cw.visitEnd();
    FileOutputStream fos = new FileOutputStream(new File(dest, "module-info.class"));
    fos.write(cw.toByteArray());
    fos.close();
}
 
Example 3
Source File: ModuleRequireNode.java    From Cafebabe with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Makes the given module visitor visit this require directive.
 *
 * @param moduleVisitor
 *          a module visitor.
 */
public void accept(final ModuleVisitor moduleVisitor) {
	moduleVisitor.visitRequire(module, access, version);
}
 
Example 4
Source File: ModuleRequireNode.java    From Concurnas with MIT License 2 votes vote down vote up
/**
 * Makes the given module visitor visit this require directive.
 *
 * @param moduleVisitor a module visitor.
 */
public void accept(final ModuleVisitor moduleVisitor) {
  moduleVisitor.visitRequire(module, access, version);
}
 
Example 5
Source File: ModuleRequireNode.java    From JByteMod-Beta with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Makes the given module visitor visit this require directive.
 * 
 * @param mv
 *          a module visitor.
 */
public void accept(final ModuleVisitor mv) {
  mv.visitRequire(module, access, version);
}
 
Example 6
Source File: ModuleRequireNode.java    From JReFrameworker with MIT License 2 votes vote down vote up
/**
 * Makes the given module visitor visit this require directive.
 *
 * @param moduleVisitor a module visitor.
 */
public void accept(final ModuleVisitor moduleVisitor) {
  moduleVisitor.visitRequire(module, access, version);
}
 
Example 7
Source File: ModuleRequireNode.java    From JReFrameworker with MIT License 2 votes vote down vote up
/**
 * Makes the given module visitor visit this require directive.
 *
 * @param moduleVisitor a module visitor.
 */
public void accept(final ModuleVisitor moduleVisitor) {
  moduleVisitor.visitRequire(module, access, version);
}