Thread: [Sablevm-developer] Reflection and interfaces
Brought to you by:
egagnon
From: Laurent M. <la...@ao...> - 2004-05-19 12:19:34
|
Hello, java.lang.Class.getMethods() returns an empty for interfaces with sablevm 1.1.4. Is it a known bug/limitation ? -- Laurent Martelli la...@ao... Java Aspect Components http://www.aopsys.com/ http://jac.objectweb.org |
From: Grzegorz B. P. <ga...@de...> - 2004-05-21 03:54:53
|
On (19/05/04 14:19), Laurent Martelli wrote: > Hello, > > java.lang.Class.getMethods() returns an empty for interfaces with > sablevm 1.1.4. Is it a known bug/limitation ? I have looked at the code of Classpath and functions called into the VM and it seems that this should be handled. I presume it's a bug then. Could somebody more insightful take a look at that? GBP PS: I am not of much help these days, but it'll change RSN. -- Grzegorz B. Prokopski <ga...@de...> Debian GNU/Linux http://www.debian.org SableVM - LGPLed JVM http://www.sablevm.org Why SableVM ?!? http://devel.sablevm.org/wiki/WhySableVM |
From: Laurent M. <la...@ao...> - 2004-05-21 10:21:32
|
>>>>> "Grzegorz" == Grzegorz B Prokopski <ga...@de...> writes: Grzegorz> On (19/05/04 14:19), Laurent Martelli wrote: >> Hello, >> >> java.lang.Class.getMethods() returns an empty for interfaces with >> sablevm 1.1.4. Is it a known bug/limitation ? Grzegorz> I have looked at the code of Classpath and functions Grzegorz> called into the VM and it seems that this should be Grzegorz> handled. I presume it's a bug then. Grzegorz> Could somebody more insightful take a look at that? I think java.lang.Class.getDeclaredMethods() should rather look like this: Method[] getDeclaredMethods (boolean publicOnly) { - if (isPrimitive() || isArray() || isInterface()) + if (isPrimitive() || isArray()) { return new Method[] { }; } else { return VMClass.getDeclaredMethods(this, publicOnly); } } I though I had already sen this to the list, but I've been using gmane and there seems to be a delay. -- Laurent Martelli la...@ao... Java Aspect Components http://www.aopsys.com/ http://jac.objectweb.org |
From: Chris P. <chr...@ma...> - 2004-05-21 13:54:31
|
Laurent Martelli wrote: >>>>>>"Grzegorz" == Grzegorz B Prokopski <ga...@de...> writes: > > > Grzegorz> On (19/05/04 14:19), Laurent Martelli wrote: > >> Hello, > >> > >> java.lang.Class.getMethods() returns an empty for interfaces with > >> sablevm 1.1.4. Is it a known bug/limitation ? > > Grzegorz> I have looked at the code of Classpath and functions > Grzegorz> called into the VM and it seems that this should be > Grzegorz> handled. I presume it's a bug then. > > Grzegorz> Could somebody more insightful take a look at that? > > I think java.lang.Class.getDeclaredMethods() should rather look like this: > > Method[] getDeclaredMethods (boolean publicOnly) > { > - if (isPrimitive() || isArray() || isInterface()) > + if (isPrimitive() || isArray()) > { > return new Method[] { }; > } > else > { > return VMClass.getDeclaredMethods(this, publicOnly); > } > } > > I though I had already sen this to the list, but I've been using gmane > and there seems to be a delay. Hi Laurent, I never got this java.lang.getDeclaredMethods() patch before and I'm subscribed to sab...@li.... I did however get a suggestion for java.lang.isAssignableFrom(). I'm not a Classpath hacker, so you'll need to wait for a response from Etienne or David about that. In the meantime, for the above, you can take a look at VMClass.getDeclaredMethods() in sablevm/src/libsablevm/java_lang_VMClass.c and maybe you'll find the problem. Also, if you want to get a recent "staging" branch of both sablevm and sablevm-classpath (this is the first-level shared developer branch), you can follow the instructions here: http://devel.sablevm.org/wiki/Getting Cheers, Chris |
From: David <db...@cs...> - 2004-05-21 16:25:28
|
On Fri, May 21, 2004 at 12:21:25PM +0200, Laurent Martelli wrote: > >>>>> "Grzegorz" =3D=3D Grzegorz B Prokopski <ga...@de...> writes: >=20 > Grzegorz> On (19/05/04 14:19), Laurent Martelli wrote: > >> Hello, > >>=20 > >> java.lang.Class.getMethods() returns an empty for interfaces with > >> sablevm 1.1.4. Is it a known bug/limitation ? >=20 > Grzegorz> I have looked at the code of Classpath and functions > Grzegorz> called into the VM and it seems that this should be > Grzegorz> handled. I presume it's a bug then. >=20 > Grzegorz> Could somebody more insightful take a look at that? >=20 > I think java.lang.Class.getDeclaredMethods() should rather look like th= is: >=20 > Method[] getDeclaredMethods (boolean publicOnly) > { > - if (isPrimitive() || isArray() || isInterface()) > + if (isPrimitive() || isArray()) > { > return new Method[] { }; > } > else > { > return VMClass.getDeclaredMethods(this, publicOnly); > } > } Hi Laurent, This is the correct fix and will make it in SableVM/staging version. Thanks, David --- David B=E9langer Graduate Student School of Computer Science McGill University Office: MC226 Web page: http://www.cs.mcgill.ca/~dbelan2/ Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt |
From: Etienne G. <gag...@uq...> - 2004-05-21 17:46:58
|
I wonder... David B=E9langer wrote: >>- if (isPrimitive() || isArray() || isInterface()) >>+ if (isPrimitive() || isArray()) >=20 > This is the correct fix and will make it in SableVM/staging version. Wouldn't the following be the correct fix? - if (isPrimitive() || isArray() || isInterface()) + if (isPrimitive()) Arrays inherit from java.lang.Object, so they have methods, isn't it? Etienne --=20 Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |
From: David <db...@cs...> - 2004-05-21 21:02:54
|
On Fri, May 21, 2004 at 01:36:07PM -0400, Etienne Gagnon wrote: > I wonder... >=20 > David B=E9langer wrote: > >>- if (isPrimitive() || isArray() || isInterface()) > >>+ if (isPrimitive() || isArray()) > > > >This is the correct fix and will make it in SableVM/staging version. >=20 > Wouldn't the following be the correct fix? >=20 > - if (isPrimitive() || isArray() || isInterface()) > + if (isPrimitive()) >=20 > Arrays inherit from java.lang.Object, so they have methods, isn't it? >=20 Yes, but getDeclaredMethods returns only methods declared by the type, not all methods inherited. Arrays do not declare them and the spec says it should return an empty array of Methods if it is an array type. If getMethods() is called (for all methods), it should correctly figure out that the superclass of the array type is Object and collect them. David --- David B=E9langer Graduate Student School of Computer Science McGill University Office: MC226 Web page: http://www.cs.mcgill.ca/~dbelan2/ Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt |
From: Etienne G. <gag...@uq...> - 2004-05-21 16:28:37
|
Laurent Martelli wrote: > I think java.lang.Class.getDeclaredMethods() should rather look like this: > > Method[] getDeclaredMethods (boolean publicOnly) > { > - if (isPrimitive() || isArray() || isInterface()) > + if (isPrimitive() || isArray()) > { > return new Method[] { }; > } > else > { > return VMClass.getDeclaredMethods(this, publicOnly); > } > } This makes sense. I have checked that code in staging, but it would be nice if you could actually test it. I have put packages for you to test on: http://www.info.uqam.ca/~egagnon/sablevm/ Please let us know it it works. Thanks! Etienne -- Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |
From: Chris P. <chr...@ma...> - 2004-05-21 14:24:54
|
Chris Pickett wrote: > Laurent Martelli wrote: >> >>I think java.lang.Class.getDeclaredMethods() should rather look like this: >> >> Method[] getDeclaredMethods (boolean publicOnly) >> { >>- if (isPrimitive() || isArray() || isInterface()) >>+ if (isPrimitive() || isArray()) >> { >> return new Method[] { }; >> } >> else >> { >> return VMClass.getDeclaredMethods(this, publicOnly); >> } >> } > > In the meantime, for the above, you can take a look at > VMClass.getDeclaredMethods() in > sablevm/src/libsablevm/java_lang_VMClass.c and maybe you'll find the > problem. That's a silly answer from me, because you're suggesting the problem is with GNU Classpath, not SableVM. Does it work for you if you make the above change to Classpath? Cheers, Chris |
From: Laurent M. <la...@ao...> - 2004-05-21 15:36:12
|
>>>>> "Chris" == Chris Pickett <chr...@ma...> writes: Chris> Chris Pickett wrote: >> Laurent Martelli wrote: >>> I think java.lang.Class.getDeclaredMethods() should rather look >>> like this: >>> >>> Method[] getDeclaredMethods (boolean publicOnly) { - if >>> (isPrimitive() || isArray() || isInterface()) + if >>> (isPrimitive() || isArray()) { return new Method[] { }; >>> } >>> else { return VMClass.getDeclaredMethods(this, publicOnly); >>> } >>> } >> In the meantime, for the above, you can take a look at >> VMClass.getDeclaredMethods() in >> sablevm/src/libsablevm/java_lang_VMClass.c and maybe you'll find >> the problem. Chris> That's a silly answer from me, because you're suggesting the Chris> problem is with GNU Classpath, not SableVM. Does it work for Chris> you if you make the above change to Classpath? Yes it does. -- Laurent Martelli la...@ao... Java Aspect Components http://www.aopsys.com/ http://jac.objectweb.org |