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 - ClassDefinition.getMethod not always working
Summary: ClassDefinition.getMethod not always working
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Jan Becicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-10 16:28 UTC by Ondrej Rypacek
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
attaching the same piece of code indented properly (314 bytes, text/plain)
2004-08-10 16:31 UTC, Ondrej Rypacek
Details

Note You need to log in before you can comment on or make changes to this bug.
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