Community
Participate
Working Groups
I use the getMethods()on an ISourceType to get all the methods for a type. The problem is that it is not returning the default constructor for a public class. This causes a problem for us since we switch between JDOM reflection and JDK reflection and in the JDK Class.getDeclaredConstructors(), the default constructor will be returned. Is there a mechanism that we are missing to return all methods including the default constructors for a SourceType?
A ISourceType is a type "from source". The default constructors doesn't appear in source. If you want all the methods (including synthetics, default constructors,...), use a binary type. The API on java.lang.Class is not using the source. It is using the binary type.
Can you get the binaryType from the SourceType so I could get the correct level of reflection?
What are you trying to do exactly?
I am trying to reflect all of the methods (including all default constructors) from a type in the workbench (I don't care if it is just binary or source).
The maximum of default constructor is one. The default constructor is by definition a constructor without any argument provided by the compiler when the class doesn't define any constructor. If you have a source type and it doesn't contain any constructor, then simply add a default constructor to your collection of methods. If you have a binary type, it will expose the default constructor.
The source model strictly reflects sources. If sources did not contain a constructor, then it is not available in the model. The fact it is generated, and thus available in corresponding binaries is a compiler artifact. No plan to change this assumption.
*** Bug 372192 has been marked as a duplicate of this bug. ***