Dominique Devienne wrote:
The fact that the meaning of <available> was overloaded in the past doesn't
mean we should continue doing so... And still, available currently looks for
files/streams (on file-system, classpath, path, etc...), which is quite
different than looking for particular characteristic of whatever's described
in these streams...
Ah, I missed this.

Condition names that could be used:
<classHasMethod>
<classHasField>
<classHasInnerClass>
<classIsAssigneableFrom>
etc...

Having separate conditions allows to associate them with <and>, <or>, etc...
as needed.
I see. I'm still wrangling with ideas about how to make it
easy to test multiple conditions of this kind on the same
class. Repeating the fully qualified class name every time
seems to be a bit bothersome, even though it's probably
tolerable.

As far as allowing to check for particular method signature, when looking
for just the method name is not enough, then the simplest thing is to use
the JNI signature, as in "main([java.lang.String)V", and have an optional
modifiers attribute. This is well documented, and avoids having to parse the
signature as written in a Java source file. Of course if you really want the
ability to say "public static void main(String[])", you're welcome to write
the parser for it ;-)

I'd thought of using XML structures and using introspection rather than looking up some string in the source: <classHasMethod class="foo" method="bar"> <parameter type="int"/> <parameter type="BazClass"/> </classHasMethod> could be roughly handled by this wild pseudocode clazz=Class.forName(@class); parameterTypes = new Class[count(parameter)]; for-each parameter parameterTypes[position()] = built-in-classes(@type) if parameterTypes[position()]==null parameterTypes[position()] = Class.forName(@type) method=clazz.getMethod(@method,parameterTypes);

J.Pietschmann



Reply via email to