Skip to main content

JAXB 2.1 regenerator plugin

Posted by kohsuke on October 12, 2006 at 6:08 PM PDT

Juraj Vitko sent me a plugin that allows you to manually put additional code to the JAXB generated classes, and yet have XJC preserve them when you regenerate source files. To use this, you have to put your code into the special marker like the following. As you can see, this is a pretty simple-minded plugin.

class X {

  ...generated code here...


  //...your code here...
  public String myFunction(String s) {
    s = s + " hello!";
    return s;

In the past, we've thought about this kind of problems very seriously. How to let you manually modify code, or change some of the generated code, and then still have XJC preserve yours. As you can imagine, in general case this is a very tough problem, so we ended up not doing anything.

It's very intersting to see people coming up with a simple solution like this. It's not a comprehensive solution, but it's good enough for many people, and needless to say it's better to do something than not doing anything! I guess here at Sun we tend to over-engineer things at times.

Related Topics >>