aspose file tools*
The moose likes Java in General and the fly likes How get method source code from a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How get method source code from a class" Watch "How get method source code from a class" New topic
Author

How get method source code from a class

avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
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

Joined: Jul 11, 2001
Posts: 14112
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.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How get method source code from a class