JSymbol implements Symbol { @Override public final String name() { if (binding.getKind() == IBinding.METHOD && ((IMethodBinding) binding).isConstructor()) { return "<init>"; } if (binding.getKind() == IBinding.TYPE && ((ITypeBinding) binding).isParameterizedType()) { return ((ITypeBinding) binding).getErasure().getName(); } return binding.getName(); } JSymbol(JSema sema, IBinding binding); @Override final boolean equals(Object obj); @Override final int hashCode(); @Override final String name(); @Override final Symbol owner(); @Override final Type type(); @Override final boolean isVariableSymbol(); @Override final boolean isTypeSymbol(); @Override final boolean isMethodSymbol(); @Override final boolean isPackageSymbol(); @Override final boolean isStatic(); @Override final boolean isFinal(); @Override final boolean isEnum(); @Override final boolean isInterface(); @Override final boolean isAbstract(); @Override final boolean isPublic(); @Override final boolean isPrivate(); @Override final boolean isProtected(); @Override final boolean isPackageVisibility(); @Override final boolean isDeprecated(); @Override final boolean isVolatile(); @Override final boolean isUnknown(); @Override final SymbolMetadata metadata(); @Nullable @Override final TypeSymbol enclosingClass(); @Override final List<IdentifierTree> usages(); @Nullable @Override Tree declaration();  }
@Test void name() { JavaTree.CompilationUnitTreeImpl cu = test("class C { C() { } void m() { } }"); ClassTreeImpl c = (ClassTreeImpl) cu.types().get(0); MethodTreeImpl constructor = (MethodTreeImpl) c.members().get(0); MethodTreeImpl method = (MethodTreeImpl) c.members().get(1); assertThat(cu.sema.typeSymbol(c.typeBinding)) .hasSameNameAs(c.symbol()) .hasName("C"); assertThat(cu.sema.methodSymbol(constructor.methodBinding)) .hasSameNameAs(constructor.symbol()) .hasName("<init>"); assertThat(cu.sema.methodSymbol(method.methodBinding)) .hasSameNameAs(method.symbol()) .hasName("m"); }