This is a follow on to the "avoid boxing" thread.

Let's assume, for the moment, that the JDK contains an infinite number
of interfaces in the java.lang.reflect.dispatch package. An example of
these looks like this:

interface Ivoii {
void fvoii(Object p1, int p2, int p3);
}

i.e. the interface has a single method and the spelling of the name of
the interface tells you the name and the signature of the method (v =
void, o = Object, i = int, b = byte, x = boolean, etc.)

I think these would be pretty handy for dynamic language implementers.

For example, if I was dynamically generating a MetaClass for each
class I could make it implement one of these interfaces for every
different message signature on the class (plus two extra Object
parameters for the name of the method and the instance).

So I could compile x.toString() as

let m be the MetaClass for x

((Iooo)m).fooo("toString", x)

If I'm calling a method not on Object and I don't know the type of x i
can still use the interface:

x.foo(1, 2, 3)

if (m instancof Ivooiii) {
  ((Ivooiii)m).fvooiii("foo", x, 1, 2, 3)
} else {
  dispatch the call the slow way
}

No that for this usage to work I need to implement up to three
interfaces for every call signature on the class. As the call cannot
tell the type of result it wants then if foo was declared as:

int foo(int a, int b, int c)...

we would have to implement Iiooiii, Ioooiii and Ivooiii when int, a
boxed int and nothing was returned in each case.

I'm not suggesting that these interfaces sit in rt.jar, of course.
Ideally, the system classloader would dynamically generate them on
demand. If that can't be managed then a custom classloader could do
the generation.

Comments?

John Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to jvm-languages@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to