OT: This is for java geeks out there

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFIwGemhMBO4cVSGS8RAmZFAJ9NtL1izKhmj40HHM/Xv1MgB7l1GACeJqOa
eTf9ku27xa1wBUAOyNQfxkg=
=MOSM
-----END PGP SIGNATURE-----

-- 
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