title: How can I add my own code to JAVA generated classes from proto file?
body: <p>I'm using protobuf and I'm generating JAVA classes from the following proto file.</p>
  
  <pre><code>syntax = "proto3";
  enum Greeting {
      NONE = 0;
      MR = 1;
      MRS = 2;
      MISS = 3;
  }
  
  message Hello {
      Greeting greeting = 1;
      string name = 2;
  }
  
  message Bye {
      string name = 1;
  }
  
  option java_multiple_files = true;
  </code></pre>
  
  <p>Now I need to add some code to the generated files and I found that is possible using a custom plugin (<a href="https://developers.google.com/protocol-buffers/docs/reference/java-generated#plugins" rel="nofollow noreferrer">https://developers.google.com/protocol-buffers/docs/reference/java-generated#plugins</a>). I'm trying to generate that plugin in Java, something like this.</p>
  
  <pre><code>public class Test {
     PluginProtos.CodeGeneratorResponse.getDefaultInstance();
     /* Code to get generated files from java_out and use the insertion points */
     codeGeneratorResponse.writeTo(System.out);
  }
  </code></pre>
  
  <p>And then I run </p>
  
  <pre><code>protoc --java_out=./classes --plugin=protoc-gen-demo=my-plugin --demo_out=. example.proto
  </code></pre>
  
  <p>The problem is that on my <code>Test.java</code> main method I don't know how to get access to the files created by the option <code>--java_out</code> so that I can use their insertion points. Currently the <code>CodeGeneratorResponse</code> for the default instance is empty (no files).</p>
  
  <p>Does anybody know how can I get the <code>CodeGeneratorResponse</code> from the --java_out so that I can add more code to the generated classes?</p>
  
  <p>Thanks in advance.</p>