This discussion is archived
4 Replies Latest reply: Dec 2, 2009 12:41 PM by 843793 RSS

Need clarification on @Generated and Filer.createSourceFile

843793 Newbie
Currently Being Moderated
As part of JAX-WS code generation, I have an interface like this:
@WebService(...)
public interface FooPortType {
...
}
And I really need it to look like this:
@WebService(...)
public interface FooPortType extends MyService {
...
}
I understand the restrictions on modifying existing source with an annotation processor, but if I can get JAX-WS to generate the interface with @Generated, will that allow Filer.createSourceFile to succeed so that I can modify it?
  • 1. Re: Need clarification on @Generated and Filer.createSourceFile
    843793 Newbie
    Currently Being Moderated
    Not quite sure what you're asking here. If the question is "Can I generate MyService with an annotation processor and have FooPortType extend the to-be-generated type?" the answer is "yes."
  • 2. Re: Need clarification on @Generated and Filer.createSourceFile
    843793 Newbie
    Currently Being Moderated
    The JAX-WS RI wsimport tool creates FooPortType and MyService already exists (it's not generated). What I need is a way for annotation processing to modify FooPortType "in place" to make it extend MyService, but I understand that's not really supported. The Javadoc for Filer seems to imply that modifying existing code might be allowed as long as it's been marked with @Generated, so I was looking for clarification on that possibility.
  • 3. Re: Need clarification on @Generated and Filer.createSourceFile
    843793 Newbie
    Currently Being Moderated
    kschneid wrote:
    The JAX-WS RI wsimport tool creates FooPortType and MyService already exists (it's not generated). What I need is a way for annotation processing to modify FooPortType "in place" to make it extend MyService, but I understand that's not really supported.
    That is not supported by annotation processing in apt or javac. To get that effect, you have to generate a superclass or subclass of the type in question.
    The Javadoc for Filer seems to imply that modifying existing code might be allowed as long as it's been marked with @Generated, so I was looking for clarification on that possibility.
    The Filer uses different checks for files coming from different locations. If a file is on the source path, it cannot be overwritten. If it is on the source output location, it can be written once. While the @Generated annotation is a recommended practice, the annotation processing infrastructure in javac does not use the presence or absence of this annotation to alter the overwriting policy.
  • 4. Re: Need clarification on @Generated and Filer.createSourceFile
    843793 Newbie
    Currently Being Moderated
    10-4. Thanks for the feedback.