Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How get method source code from a class

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

We developed a model generator tool that get a �base model� as an input and generated rich model.
The �base model� is collection of POJO classes and the model generator analyzed the base model (with reflection) and with �ftl� generates �rich model� , which is the base model with additional annotations and logics.

Some classes in the �base-model� may contain additional method and I need to copy those methods as they are to the �rich-model� generated sources.

I need a way to copy those methods from the base-model (I work on it with reflection, but I have also the source) to the rich-model.

I think to do this by decompile. Are there any better way?
Is there any simple utility that decompile method?


Thank you
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were in that situation, I'd probably evaluate whether I could make use of the Decorator design pattern instead. That is, let the newly generated classes delegate to the original classes were appropriate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic