Summary: | [1.5] treatment of Object.getClass() not API compliant | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Adam Kiezun <akiezun> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | jeem |
Version: | 3.1 | ||
Target Milestone: | 3.1 M6 | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Adam Kiezun
2005-03-19 14:12:16 EST
The method is strictly declared as of type: Class<? extends Object> on the declaration side. Only the compiler is translating this type on the fly when this method gets invoked. Blame the spec. the problem is that the results returned by JCORE APIs are inconsistent with JCORE docs. The API docs say one thing, and the actual results do another thing. Stricly speaking this is an documentation bug. I think the implementation is allright. Ok, we can mention this in the spec. Would this be good enough? /** * <p>Returns the binding for the method declaration corresponding to this * method binding. For parameterized methods ({@link #isParameterizedMethod()}) * and raw methods ({@link #isRawMethod()}), this method returns the binding * for the corresponding generic method. For other method bindings, this * returns the same binding.</p> * * <p>Note: The only exception is the method <code>java.lang.Object.getClass<? extends Object></code>. * When used in code, this method returns the method binding corresponding to its * declaration in <code>java.lang.Object</code>. * </p> * * @return the method binding * @since 3.1 */ what about ? Note: A noticeable exception is the method Object.getClass() which is declared to return Class<? extends Object>, but in reality when invoked its return gets substituted into Class<? extends R>, where R is the receiver type of the method invocation. jim - can you double check phrasing ? how about ? Note: The one notable exception is the method <code>Object.getClass()</code>, which is declared to return <code>Class<? extends Object></code>, but when invoked its return type becomes <code>Class<? extends </code><em>R</em><code>></code>, where <em>R</em> is the receiver type of the method invocation. you might want to mention that it is the _static_ type of the receiver, not the run-time type So we would end up with: Note: The one notable exception is the method <code>Object.getClass()</code>, which is declared to return <code>Class<? extends Object></code>, but when invoked its return type becomes <code>Class<? extends </code><em>R</em><code>></code>, where <em>R</em> is the static type of the receiver of the method invocation, not the runtime type. I released this version: Note: The one notable exception is the method <code>Object.getClass()</code>, which is declared to return <code>Class<? extends Object></code>, but when invoked its return type becomes <code>Class<? extends </code><em>R</em><code>></code>, where <em>R</em> is the compile type of the receiver of the method invocation. Verified in 20050330-0500. I will open a new bug report to improve the formatting of the doc. The note should be in its own paragraph. |