Community
Participate
Working Groups
I20050811-1530 The javadoc of ITypeBinding#getBinaryName() says: * The binary name of a class is defined in the Java Language * Specification 2nd edition, section 13.1. It is not clear what should be returned for type variables. Currently, the method returns java.lang.Object. I would expect to get either null, or the binary name as defined in JLS3. No big deal for me right now, just an API glitch.
Jim, Could you please clarify the specs? Once done, I will adjust the implementation.
In fact according to the spec, null can safely be returned for type variables. I'll adjust the spec and the implementation. java.lang.Object seems to be wrong anyway.
I think we should inline the spec with the JLS3 specification that clearly states what the binary name should be for different cases of type variables. I'll implement the JLS3 specifications.
My understanding is that binary name for T in: - class X<T> {} is X$T - class X { <T> void foo() { ... } } is X$()V$T - class X { <T> X() { ... } } is X$()V$T I would have expected the method selector to be part of the binary name, but this is not the case. Markus, could you please confirm that you end up with the same binary names?
(In reply to comment #4) Looks good to me in that it conforms to the JLS3. But I think the spec is seriously broken here, since binary names are not unique any more (although one could argue that method type variables only make sense in the context of the declaring method, and there, they are still unique). I guess the creators of J2SE-6 must have implemented this in javax.lang.model.util.Elements.getBinaryName(TypeElement), but I didn't try it out, since AFAICS, the Eclipse APT support for 1.6 is not yet ready.
I'll try to make some experiments. Thanks for your reply.
javax.lang.model.util.Elements.getBinaryName(TypeElement) cannot be applied on type parameters elements.
Released for 3.3M6. Markus, let me know if this corresponds to what you expected.
Per https://docs.oracle.com/javase/specs/jls/se6/html/binaryComp.html#13.1: "The binary name of a type variable declared by a generic method is the binary name of the type declaring the method, followed by $, followed by the descriptor of the method as defined in the Java Virtual Machine Specification, followed by $, followed by the simple name of the type variable." This is also true in the latest version of the spec, http://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.1: "The binary name of a type variable declared by a generic method (§8.4.4) is the binary name of the type declaring the method, followed by $, followed by the descriptor of the method (JVMS §4.3.3), followed by $, followed by the simple name of the type variable.: So JLS actually defines the name of the method as part of the binary name; since it is missing the API doesn't follow its contract and the generated names are not unique anymore.