JDK-6423973 : getReturnType() returns VoidType for a constructor
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-10
  • Updated: 2011-01-19
  • Resolved: 2006-07-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b91Fixed
Related Reports
Relates :  
Relates :  
Description
The specification for the method getReturnType() in javax.lang.model.element.ExecutableElement says:

---
TypeMirror getReturnType()
    Returns the return type if this executable represents *a method*. Returns *NoType otherwise*. Returns VoidType if this executable is a method that does not return a value.

       ...
---

  For a constructor in the following example VoidType is returned:

public class S_EE0004 extends TestSource {
    public S_EE0004(Integer param) {}
}

Comments
EVALUATION Change getReturnType() spec in ExecutableElement and ExecutableType to read: * Returns the return type of this executable. * Returns a NoType with kind VOID * if this executable is not a method, or is a method that does not * return a value.
23-06-2006

EVALUATION NoType and VoidType have a lot in common: they're both used to indicate "no type is appropriate/available". Internally, javac represents the return type of a constructor as VoidType. Either the spec or the implementation must be changed so the two agree.
13-05-2006