This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I'm trying to retrieve the main(String[]) method by the following code from a class that definitely contains a main method. public static boolean hasMainMethod(JavaClass cls) { JavaModelPackage pkg = (JavaModelPackage)cls.refImmediatePackage(); return cls.getMethod("main", Collections.singletonList(pkg.getArray().resolveArray(TestUtil.getStringType(pkg))), false) != null; } the cls.getMethod... call always returns null.
Created attachment 16726 [details] attaching the same piece of code indented properly
I don't know, what TestUtil.getStringType(pkg) exactly does, but it worksforme. Method me = clazz.getMethod("main", Collections.singletonList(pkg.getArray().resolveArray(pkg.getType().resolve("java.lang.String"))), false); successfuly returned main method.
Sorry, I forgot. getStringType does exactly what you have there... ...with a subtle difference though: pkg.getType().resolve("String") It remained there from my previous attempts to get it working. Previously neither with "String" nor with "java.lang.String" was working. Now, with the latest version, "java.lang.String" works fine. Thanks anyway for the evaluation. It always helps to get somebody else have a look at a problem :-)
Reorganization of java component