3

Is it possible to get a list of system apex classes like String, Datetime etc. and a list of their methods, fields etc. using soap or metadata or tooling api in java?

4

Apex Code doesn't have proper "reflection" like actual Java. Furthermore, the system classes do not expose their source code. Many system classes are actually not real classes, but pseudo-classes that violate the normal rules of a class.

For example, with a normal class, you can say something like x instanceOf DateTime), but you can't do that with System (e.g. x instanceOf System won't compile).

It has static methods like System.now(), but you get unusual compiler errors when you try to use it as a class (e.g. new System() gives an error "Invalid type: System" instead of "Type cannot be constructed: DateTime" from new DateTime() or "Invalid constructor", etc).

Since they're not real classes, we couldn't reflect them anyways. The syntax is made in a way that facilitates the appearance of being real classes, but not being actual classes.

  • Thank you for the answer. Could you please tell me does it concern all namespaces listed here? salesforce.com/us/developer/docs/apexcode/… – Liudmila Likhovid Oct 24 '14 at 19:57
  • And one more question about installed packages. I usually get them using retrieve call where I need to list names of my installed packages. But before I need to get this list of names. When I do listMetadata call with query type InstalledPackage, in resulting objects field FullName is the same as NamespacePrefix. For example FullName is "Rknews" instead of "Redhot news". Is there any way to get list of installed packages' names? – Liudmila Likhovid Oct 24 '14 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.