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]

Dynamic Abstract Interface


I'm attempting to build an abstract class definition, something that looks like this, eventually (I want to be able to use it will JNA transparently):

? public interface com.sun.jna.examples.BeepExample$Kernel32 extends com.sun.jna.Library
? {
??? public abstract boolean Beep(int, int);
??? public abstract void Sleep(int);
? }

So my first thought was to use define-class, but it doesn't appear that define-class has the fine-grained controls to do something like this.

So I turned to building it by hand using gnu.expr.* and gnu.bytecode.* and using a NEW ArrayClassLoader.

Well this worked, for a static case.? 

Then the next problem I came across was if I wanted to dynamically update that interface, i.e. add a 'void printf' or something.? I couldn't do it because the class definition was 'locked' by the ClassLoader.? So, my next step was to generate a hash keeping track of what's stored in our ClassLoader and then creating a fresh ArrayClassLoader and redefining everything from the hash and then updating the static ArrayClassLoader reference.? This seemed to work for adding new definitions.

Now the problem I'm having is I can't figure out how to intermingle the ArrayClassLoader definition I had and the ClassLoader used by Kawa.

So if I use the ArrayClassLoader to define an abstract class and then want to reference that class inside of a (define-simple-class...) or (define-class...) statement, it fails because it can't find it in the Kawa ClassLoader.

So, my question is, what's the best way of going about this?

I'm not terribly familiar with the Kawa inner-workings, but my first thought would be to duplicate (define-class) with a (define-interface-class) or something like that.? But, I'm not entirely sure where to start and what would ABSOLUTELY be necessary for that to occur.

I know that Kawa supports 'adding' definitions to the ClassLoader because if you do a (define-class <a>...) and then (define-class <a>...more stuff...) it works, so under the covers the ClassLoader is being updated dynamically.? So, can I replicate this behaviour in a JAR outside of Kawa for abstract interfaces or does Kawa only support low-level operations like this to occur within the framework?


From,
Beau Croteau
Beau.croteau@ca.com


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