• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Annotations changing Source Code  RSS feed

 
garz faust
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i want to write an annotation that is able to carry type parameter from super class declaration to sub class declarations. Assumed the following scenario:

Problem with this is, if a type parameter changes, i have to adjust all of them in every sub class by hand. The idea is to develop an annotation that can carry type declarations to the corresponding subclasses. Like this:

The annotation is responsible for completing the declaration of the sub class.

I know how to develop annotations, i know that i need an annotation processor and i know the mirrors api. What i don't know is, how to alter the source code. So i'm asking, is there any convenient way to do this or is it pain?
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if it's possible but maybe you could alter bytecode with a manipulator like javassist.
You'll probably need a custom class loader for that because once a class has been loaded it
can't be changed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!