コード例 #1
0
  public void writeInvokers(File destination) throws IOException {
    for (InvokerDescriptor descriptor : invokerDescriptors) {
      byte[] invokerBytes =
          Helpers.defOffline(
              descriptor.getRubyName(),
              descriptor.getJavaName(),
              descriptor.getClassname(),
              descriptor.getInvokerName(),
              descriptor.getArity(),
              descriptor.getScope(),
              descriptor.getCallConfig(),
              descriptor.getFile(),
              descriptor.getLine());

      if (VERIFY_CLASSFILES)
        CheckClassAdapter.verify(new ClassReader(invokerBytes), false, new PrintWriter(System.err));

      writeClassFile(destination, invokerBytes, descriptor.getInvokerName());
    }

    for (BlockCallbackDescriptor descriptor : blockCallbackDescriptors) {
      byte[] callbackBytes =
          Helpers.createBlockCallbackOffline(
              descriptor.getClassname(),
              descriptor.getMethod(),
              descriptor.getFile(),
              descriptor.getLine());

      if (VERIFY_CLASSFILES)
        CheckClassAdapter.verify(
            new ClassReader(callbackBytes), false, new PrintWriter(System.err));

      writeClassFile(destination, callbackBytes, descriptor.getCallbackName());
    }

    for (BlockCallbackDescriptor descriptor : blockCallback19Descriptors) {
      byte[] callbackBytes =
          Helpers.createBlockCallback19Offline(
              descriptor.getClassname(),
              descriptor.getMethod(),
              descriptor.getFile(),
              descriptor.getLine());

      if (VERIFY_CLASSFILES)
        CheckClassAdapter.verify(
            new ClassReader(callbackBytes), false, new PrintWriter(System.err));

      writeClassFile(destination, callbackBytes, descriptor.getCallbackName());
    }
  }
コード例 #2
0
  private void writeClass(String classname, File destination, ClassWriter writer)
      throws IOException {
    // verify the class
    byte[] bytecode = writer.toByteArray();
    if (VERIFY_CLASSFILES)
      CheckClassAdapter.verify(new ClassReader(bytecode), false, new PrintWriter(System.err));

    writeClassFile(destination, bytecode, classname);
  }