| Summary: | Types#erasure() doesn't return the raw type. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Kevin Pollet <pollet.kevin> | ||||
| Component: | APT | Assignee: | Jay Arthanareeswaran <jarthana> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | eclipse, jarthana, kozakcsabi, sasikanth.bharadwaj, srikanth_sankaran | ||||
| Version: | 3.6 | ||||||
| Target Milestone: | 4.6 M1 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| See Also: |
https://git.eclipse.org/r/52615 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=80f6342a7f709a2d6fe0cf3f1274abc00b566ec7 |
||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Kevin Pollet
Created attachment 191662 [details]
A workspace with an annotation processor to reproduce the bug
This bug still exists with Eclipse 4.3.2 on Linux. Is this going to be fixed? The Types.erasure() simply invoked ReferenceBinding#erasure() and the TypeBinding returned by ReferenceBinding#erasure() includes the type variables. And since this type binding is generic, DeclaredType#getTypeArguments() returns the type variables. In other words, MyClass<T> is expected output with the code. And the Javadoc of Types#erasure() simply states: "Returns the erasure of a type" Srikanth, can you please confirm? This is indeed a problem. "Type erasure is a mapping from types (possibly including parameterized types and type variables) to types (that are never parameterized types or type variables)." https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.6 In javac, erasure() returns the erased type correctly, for example List<T> -> List List<String> -> List However in Eclipse: List<T> -> List<T> List<String> -> List<T> This causes problems for annotation processors who are relying on the correct behavior (specified by the the JLS). Sasi, can you please respond to my question from comment #3? We basically need to replace the erasure() calls inside TypesImpl#erasure() with something that will give us the binding without the type parameter/argument. (In reply to comment #5) > Sasi, can you please respond to my question from comment #3? We basically need > to replace the erasure() calls inside TypesImpl#erasure() with something that > will give us the binding without the type parameter/argument. Yes, something like LE.convertToRawType seems to be needed here Sorry for chiming in here, but do you need more info? I just ran into this again, i started to debug my processor and after i realized actually JDT has a bug. :S Will look at this for 4.6. New Gerrit change created: https://git.eclipse.org/r/52615 Gerrit change https://git.eclipse.org/r/52615 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=80f6342a7f709a2d6fe0cf3f1274abc00b566ec7 Fixed now. Verified for 4.6 M1 using I20150804-2000 build |