Search code examples
javajakarta-eeptc-windchill

Error in making array of class


I have got below code snippet after decompiling a java class file. The original class was created in java 1.4. Now I am trying to compile in Java 1.6. I am using eclipse Juno.

Public class[] getClassTypes()
 {
return (new class[] {wt.part.WTPart});
}

But when I compile it I get the error 'wt.part.WTPart can not be resolved to a variable'

When I browse in my eclipse WS, I can see class WTPart is present in my project. Is decompiler has missed something/syntax error?

My understanding from this code is that this method just returns a list of class.

Updte:

    import wt.part.WTPart;
    ...
    ...

Public class[] getClassTypes()
 { WTPart a= new WTPart();
  wt.part.WTPart b= new wt.part.WTPart();

return (new class[] {wt.part.WTPart});
}

I don't get error at the creation of a and b. Only at the return statement I get this error. Thanks


Solution

  • You missed the '.class', and the 'class[]' should be upper case : 'Class[]'

    return (new Class[] {wt.part.WTPart.class});