[RFC] netx: search for main method in superclasses of the main class

Dr Andrew John Hughes ahughes at redhat.com
Thu Aug 5 04:30:10 PDT 2010

On 17:46 Wed 04 Aug     , Omair Majid wrote:
> Hi,
> The attached patch makes netx search for the main method in the 
> superclasses of the main class. This patch allows JOSM [1] to work with 
> Netx.
> Some applications like JOSM declare a main class which does not contain 
> a main method - the main method is declared in a superclass instead. The 
> tar file attached contains a simple example of such an application. With 
> the current version of netx, it throws an exception, saying that the 
> main method can not be found. The attached patch moves some the method 
> lookup code into a findMainMethod() which also loops through the 
> superclasses looking for the main method if it is not found in the 
> declared main class.
> Any comments or concerns?
> Cheers,
> Omair
> [1] http://josm.openstreetmap.de/download/josm.jnlp

Using getMethod rather than getDeclaredMethod:


would perform the looping over the superclasses and superinterfaces;

'Let C be the class represented by this object:

   1. C is searched for any matching methods. If no matching method is found, the algorithm of step 1 is invoked recursively on the superclass of C.
   2. If no method was found in step 1 above, the superinterfaces of C are searched for a matching method. If any such method is found, it is reflected.'

Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

More information about the distro-pkg-dev mailing list