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.

Bug 47058

Summary: ClassDefinition.getMethod not always working
Product: java Reporter: Ondrej Rypacek <rypacek>
Component: UnsupportedAssignee: Jan Becicka <jbecicka>
Status: RESOLVED INVALID    
Severity: blocker    
Priority: P2    
Version: 4.x   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: attaching the same piece of code indented properly

Description Ondrej Rypacek 2004-08-10 16:28:11 UTC
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.
Comment 1 Ondrej Rypacek 2004-08-10 16:31:26 UTC
Created attachment 16726 [details]
attaching the same piece of code indented properly
Comment 2 Jan Becicka 2004-08-11 13:05:18 UTC
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.
Comment 3 Ondrej Rypacek 2004-08-11 14:12:02 UTC
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 :-)
Comment 4 Quality Engineering 2007-09-20 12:08:44 UTC
Reorganization of java component