Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Custom Annotations changing Source Code

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
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.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic