This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: modify existing class?


LuboÅ Svoboda wrote:
Hello,
is it posible to modify existing class using kawa?

In theory, but I haven't tried to do that - it hasn't been a priority.

For example, I
would like to remove final modifier of the class and then save .class
to the filesystem.
I've tried following code but it doesn't work for my idea:

ClassType ct = ClassType.make("test.MyFinalClass");

This will "read" class information from the JVM, using reflection. I.e. this won't get the actual bytecode.

To actually read the class from a .class file (i.e. getting the bytecode
and the other "raw" attributes you need to use ClassFileInput.
Currently, this is only used by the disassembler - see the dump
class, which extends ClassFileInput.   It would be nice to make
that a little more automatic, I agree.

Even so, I don't know how well it would work to modify the
class - just adding a PUBLIC modifier seems like it should
work - but I haven't tested that sort of thing.  For more
serious class-file modification, the ASM toolkit might be better.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]