Re: OT: This is for java geeks out there

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christoph Höger wrote:
> Hi,
> 
> I do not know where to ask that, so I try it here:
> 
> I want to load a (dynamically created) class via URL ClassLoader and
> then invoke a public static method on it.
> 
> Here is the code:
> 
> 		Class lexerDefs = Class.forName("parser.LexerDefs", true, loader);
> 		
> 		Method getLexerDefs = null;
> 		
> 		try {
> 			getLexerDefs = lexerDefs.getMethod("lexerDefs", new Class[] {});
> 		} catch (NoSuchMethodException e) {
> 			fail("Class " + lexerDefs.getName() + " has no method lexerDefs()\n"
> + e.getMessage());
> 		}
> 		
> 		parser.Options.inputFile = this.inputFile;
> 
> 		System.err.println("invoking: " + getLexerDefs.toString());		
> 
> 		Object retObject = getLexerDefs.invoke(null, new Object[0]);
> 
> But all I get is:
> 	Class test.TestParserGenerator can not access a member of class
> parser.LexerDefs with modifiers "public static"
> 
> So loading class seems to work, but I cannot invoke a _public_ method? Why?
> 
> Anyone knows about reflection?

Yes.  Does a public static method with that exact signature "()" exist?
In the classpath?  What if you call it directly?

Andrew.

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux