JDK-8186875 : Removed unused method LinkFactory.getTypeAnnotationLinks(LinkInfo linkInfo)
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-08-28
  • Updated: 2017-09-29
  • Resolved: 2017-09-21
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 10
10 b25Fixed
Related Reports
Relates :  
Description
The method getTypeAnnotationLinks() of  class jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory is uncovered by tests.
This method is overridden in LinkFactoryImpl and is not used anywhere. Should we make it abstract? 
Comments
There are two methods in LinkFactory, with overrides in LinkFactoryImpl. Line 226: protected abstract Content getTypeAnnotationLink(LinkInfo linkInfo, AnnotationMirror annotation); Line 285: public Content getTypeAnnotationLinks(LinkInfo linkInfo) { Since the second of these (getTypeAnnotationLinks -- plural) is overridden, the method body as provided can never be called, meaning it is dead code. (i.e. the method can be changed to be an abstract method with no locally defined method body.) This dead method body appears to be the only use of the first of these methods (getAnnotationLink -- singular) and so its declaration and implementation (which just throws RunTimeException) also look like dead code that can be removed.
05-09-2017

Is it LinkFactory.getTypeAnnotationLinks() is this an invalid signature here ? There is public Content getTypeAnnotationLinks(LinkInfo linkInfo) {....} and there are calls to this from other parts of LinkFactory. The method getTypeAnnotationLinks(LinkInfo linkInfo) {....} does call getTypeAnnotationLink(linkInfo, anno), which will throw the RuntimeException("NYI") so I am confused.
04-09-2017

Agreed with Andrey N. This is not about "making a metrics tool happy". This is about reacting to a report that there is dead code in the product. If the method is really dead code, it should be removed. I also note this dead code is will probably call getTypeAnnotationLink, whose sole implementation unconditionally throws new RuntimeException("Not implemented yet!"); so that method, and its abstract declaration is also dead code that can be removed. -- Jon
01-09-2017

@Kumar, use the IDE of your choice to verify this method cannot be called.
01-09-2017

Use asm or classfile library and get a report of all unused methods ? Then ANC can check against that and do the right thing.
01-09-2017

I can do it for you.:) I can add this method in ANC filter. But still should know method is not used anywhere.
01-09-2017

Hmm I am hesitant to make changes to the product code to make a metrics tool happy. Is there a way that jcov can analyze unused methods and ignore those or maybe a post process pass ?
31-08-2017

Kumar, this method is overridden in LinkFactoryImpl and is not used anywhere. Should we make it abstract?
31-08-2017

SampleAPI ?
29-08-2017