Fri, 03 May 2013 17:44:38 -0700
8008768: Using {@inheritDoc} in simple tag defined via -tag fails
Reviewed-by: jjg, mduigou
Contributed-by: jonathan.gibbons@oracle.com, mike.duigou@oracle.com
1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri May 03 15:08:47 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri May 03 17:44:38 2013 -0700 1.3 @@ -1497,7 +1497,7 @@ 1.4 * @param htmltree the content tree to which the comment will be added 1.5 */ 1.6 public void addInlineComment(Doc doc, Tag tag, Content htmltree) { 1.7 - addCommentTags(doc, tag.inlineTags(), false, false, htmltree); 1.8 + addCommentTags(doc, tag, tag.inlineTags(), false, false, htmltree); 1.9 } 1.10 1.11 /** 1.12 @@ -1557,11 +1557,26 @@ 1.13 */ 1.14 private void addCommentTags(Doc doc, Tag[] tags, boolean depr, 1.15 boolean first, Content htmltree) { 1.16 + addCommentTags(doc, null, tags, depr, first, htmltree); 1.17 + } 1.18 + 1.19 + /** 1.20 + * Adds the comment tags. 1.21 + * 1.22 + * @param doc the doc for which the comment tags will be generated 1.23 + * @param holderTag the block tag context for the inline tags 1.24 + * @param tags the first sentence tags for the doc 1.25 + * @param depr true if it is deprecated 1.26 + * @param first true if the first sentence tags should be added 1.27 + * @param htmltree the documentation tree to which the comment tags will be added 1.28 + */ 1.29 + private void addCommentTags(Doc doc, Tag holderTag, Tag[] tags, boolean depr, 1.30 + boolean first, Content htmltree) { 1.31 if(configuration.nocomment){ 1.32 return; 1.33 } 1.34 Content div; 1.35 - Content result = new RawHtml(commentTagsToString(null, doc, tags, first)); 1.36 + Content result = new RawHtml(commentTagsToString(holderTag, doc, tags, first)); 1.37 if (depr) { 1.38 Content italic = HtmlTree.I(result); 1.39 div = HtmlTree.DIV(HtmlStyle.block, italic);
2.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java Fri May 03 15:08:47 2013 -0700 2.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java Fri May 03 17:44:38 2013 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -60,8 +60,8 @@ 2.11 2.12 /** 2.13 * Will return false because this inline tag may 2.14 - * only appear in Methods. 2.15 - * @return false since this is not a method. 2.16 + * not appear in Fields. 2.17 + * @return false 2.18 */ 2.19 public boolean inField() { 2.20 return false; 2.21 @@ -69,8 +69,8 @@ 2.22 2.23 /** 2.24 * Will return false because this inline tag may 2.25 - * only appear in Methods. 2.26 - * @return false since this is not a method. 2.27 + * not appear in Constructors. 2.28 + * @return false 2.29 */ 2.30 public boolean inConstructor() { 2.31 return false; 2.32 @@ -78,8 +78,8 @@ 2.33 2.34 /** 2.35 * Will return false because this inline tag may 2.36 - * only appear in Methods. 2.37 - * @return false since this is not a method. 2.38 + * not appear in Overview. 2.39 + * @return false 2.40 */ 2.41 public boolean inOverview() { 2.42 return false; 2.43 @@ -87,20 +87,20 @@ 2.44 2.45 /** 2.46 * Will return false because this inline tag may 2.47 - * only appear in Methods. 2.48 - * @return false since this is not a method. 2.49 + * not appear in Packages. 2.50 + * @return false 2.51 */ 2.52 public boolean inPackage() { 2.53 return false; 2.54 } 2.55 2.56 /** 2.57 - * Will return false because this inline tag may 2.58 - * only appear in Methods. 2.59 - * @return false since this is not a method. 2.60 + * Will return true because this inline tag may 2.61 + * appear in Type (Class). 2.62 + * @return true 2.63 */ 2.64 public boolean inType() { 2.65 - return false; 2.66 + return true; 2.67 } 2.68 2.69 /** 2.70 @@ -109,12 +109,13 @@ 2.71 * of @inheritDoc with documentation from it's superclass or superinterface. 2.72 * 2.73 * @param writer the writer that is writing the output. 2.74 - * @param md the {@link MethodDoc} that we are documenting. 2.75 - * @param holderTag the tag that holds the inheritDoc tag. 2.76 + * @param ped the {@link ProgramElementDoc} that we are documenting. 2.77 + * @param holderTag the tag that holds the inheritDoc tag or null for type 2.78 + * (class) docs. 2.79 * @param isFirstSentence true if we only want to inherit the first sentence. 2.80 */ 2.81 private TagletOutput retrieveInheritedDocumentation(TagletWriter writer, 2.82 - MethodDoc md, Tag holderTag, boolean isFirstSentence) { 2.83 + ProgramElementDoc ped, Tag holderTag, boolean isFirstSentence) { 2.84 TagletOutput replacement = writer.getTagletOutputInstance(); 2.85 2.86 Configuration configuration = writer.configuration(); 2.87 @@ -122,20 +123,30 @@ 2.88 null : configuration.tagletManager.getTaglet(holderTag.name()); 2.89 if (inheritableTaglet != null && 2.90 !(inheritableTaglet instanceof InheritableTaglet)) { 2.91 + String message = ped.name() + 2.92 + ((ped instanceof ExecutableMemberDoc) 2.93 + ? ((ExecutableMemberDoc)ped).flatSignature() 2.94 + : ""); 2.95 //This tag does not support inheritence. 2.96 - configuration.message.warning(md.position(), 2.97 - "doclet.noInheritedDoc", md.name() + md.flatSignature()); 2.98 + configuration.message.warning(ped.position(), 2.99 + "doclet.noInheritedDoc", message); 2.100 } 2.101 DocFinder.Output inheritedDoc = 2.102 - DocFinder.search(new DocFinder.Input(md, 2.103 + DocFinder.search(new DocFinder.Input(ped, 2.104 (InheritableTaglet) inheritableTaglet, holderTag, 2.105 isFirstSentence, true)); 2.106 - if (inheritedDoc.isValidInheritDocTag == false) { 2.107 - configuration.message.warning(md.position(), 2.108 - "doclet.noInheritedDoc", md.name() + md.flatSignature()); 2.109 - } else if (inheritedDoc.inlineTags.length > 0) { 2.110 - replacement = writer.commentTagsToOutput(inheritedDoc.holderTag, 2.111 - inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence); 2.112 + if (inheritedDoc.isValidInheritDocTag) { 2.113 + if (inheritedDoc.inlineTags.length > 0) { 2.114 + replacement = writer.commentTagsToOutput(inheritedDoc.holderTag, 2.115 + inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence); 2.116 + } 2.117 + } else { 2.118 + String message = ped.name() + 2.119 + ((ped instanceof ExecutableMemberDoc) 2.120 + ? ((ExecutableMemberDoc)ped).flatSignature() 2.121 + : ""); 2.122 + configuration.message.warning(ped.position(), 2.123 + "doclet.noInheritedDoc", message); 2.124 } 2.125 return replacement; 2.126 } 2.127 @@ -149,11 +160,11 @@ 2.128 * @return the TagletOutput representation of this <code>Tag</code>. 2.129 */ 2.130 public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) { 2.131 - if (! (tag.holder() instanceof MethodDoc)) { 2.132 + if (! (tag.holder() instanceof ProgramElementDoc)) { 2.133 return tagletWriter.getOutputInstance(); 2.134 } 2.135 return tag.name().equals("@inheritDoc") ? 2.136 - retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), null, tagletWriter.isFirstSentence) : 2.137 - retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), tag, tagletWriter.isFirstSentence); 2.138 + retrieveInheritedDocumentation(tagletWriter, (ProgramElementDoc) tag.holder(), null, tagletWriter.isFirstSentence) : 2.139 + retrieveInheritedDocumentation(tagletWriter, (ProgramElementDoc) tag.holder(), tag, tagletWriter.isFirstSentence); 2.140 } 2.141 }
3.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java Fri May 03 15:08:47 2013 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java Fri May 03 17:44:38 2013 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -101,14 +101,14 @@ 3.11 } 3.12 } 3.13 ParamTag[] tags = input.isTypeVariableParamTag ? 3.14 - input.method.typeParamTags() : input.method.paramTags(); 3.15 + ((MethodDoc)input.element).typeParamTags() : ((MethodDoc)input.element).paramTags(); 3.16 Map<String, String> rankMap = getRankMap(input.isTypeVariableParamTag ? 3.17 - (Object[]) input.method.typeParameters() : 3.18 - (Object[]) input.method.parameters()); 3.19 + (Object[]) ((MethodDoc)input.element).typeParameters() : 3.20 + (Object[]) ((MethodDoc)input.element).parameters()); 3.21 for (int i = 0; i < tags.length; i++) { 3.22 if (rankMap.containsKey(tags[i].parameterName()) && 3.23 rankMap.get(tags[i].parameterName()).equals((input.tagId))) { 3.24 - output.holder = input.method; 3.25 + output.holder = input.element; 3.26 output.holderTag = tags[i]; 3.27 output.inlineTags = input.isFirstSentence ? 3.28 tags[i].firstSentenceTags() : tags[i].inlineTags();
4.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java Fri May 03 15:08:47 2013 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java Fri May 03 17:44:38 2013 -0700 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -50,9 +50,9 @@ 4.11 * {@inheritDoc} 4.12 */ 4.13 public void inherit(DocFinder.Input input, DocFinder.Output output) { 4.14 - Tag[] tags = input.method.tags("return"); 4.15 + Tag[] tags = input.element.tags("return"); 4.16 if (tags.length > 0) { 4.17 - output.holder = input.method; 4.18 + output.holder = input.element; 4.19 output.holderTag = tags[0]; 4.20 output.inlineTags = input.isFirstSentence ? 4.21 tags[0].firstSentenceTags() : tags[0].inlineTags();
5.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java Fri May 03 15:08:47 2013 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java Fri May 03 17:44:38 2013 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -49,9 +49,9 @@ 5.11 * {@inheritDoc} 5.12 */ 5.13 public void inherit(DocFinder.Input input, DocFinder.Output output) { 5.14 - Tag[] tags = input.method.seeTags(); 5.15 + Tag[] tags = input.element.seeTags(); 5.16 if (tags.length > 0) { 5.17 - output.holder = input.method; 5.18 + output.holder = input.element; 5.19 output.holderTag = tags[0]; 5.20 output.inlineTags = input.isFirstSentence ? 5.21 tags[0].firstSentenceTags() : tags[0].inlineTags();
6.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Fri May 03 15:08:47 2013 -0700 6.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java Fri May 03 17:44:38 2013 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -26,6 +26,7 @@ 6.11 package com.sun.tools.doclets.internal.toolkit.taglets; 6.12 6.13 import com.sun.javadoc.*; 6.14 +import com.sun.tools.doclets.internal.toolkit.util.DocFinder; 6.15 6.16 /** 6.17 * A simple single argument custom tag. 6.18 @@ -38,7 +39,7 @@ 6.19 * @author Jamie Ho 6.20 */ 6.21 6.22 -public class SimpleTaglet extends BaseTaglet { 6.23 +public class SimpleTaglet extends BaseTaglet implements InheritableTaglet { 6.24 6.25 /** 6.26 * The marker in the location string for excluded tags. 6.27 @@ -199,6 +200,17 @@ 6.28 return false; 6.29 } 6.30 6.31 + @Override 6.32 + public void inherit(DocFinder.Input input, DocFinder.Output output) { 6.33 + Tag[] tags = input.element.tags(tagName); 6.34 + if (tags.length > 0) { 6.35 + output.holder = input.element; 6.36 + output.holderTag = tags[0]; 6.37 + output.inlineTags = input.isFirstSentence 6.38 + ? tags[0].firstSentenceTags() : tags[0].inlineTags(); 6.39 + } 6.40 + } 6.41 + 6.42 /** 6.43 * {@inheritDoc} 6.44 */
7.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java Fri May 03 15:08:47 2013 -0700 7.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java Fri May 03 17:44:38 2013 -0700 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -60,15 +60,15 @@ 7.11 throwsTag.exceptionName() : 7.12 throwsTag.exception().qualifiedName(); 7.13 } else { 7.14 - exception = input.method.containingClass().findClass(input.tagId); 7.15 + exception = input.element.containingClass().findClass(input.tagId); 7.16 } 7.17 7.18 - ThrowsTag[] tags = input.method.throwsTags(); 7.19 + ThrowsTag[] tags = ((MethodDoc)input.element).throwsTags(); 7.20 for (int i = 0; i < tags.length; i++) { 7.21 if (input.tagId.equals(tags[i].exceptionName()) || 7.22 (tags[i].exception() != null && 7.23 (input.tagId.equals(tags[i].exception().qualifiedName())))) { 7.24 - output.holder = input.method; 7.25 + output.holder = input.element; 7.26 output.holderTag = tags[i]; 7.27 output.inlineTags = input.isFirstSentence ? 7.28 tags[i].firstSentenceTags() : tags[i].inlineTags();
8.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java Fri May 03 15:08:47 2013 -0700 8.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java Fri May 03 17:44:38 2013 -0700 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -48,9 +48,9 @@ 8.11 */ 8.12 public static class Input { 8.13 /** 8.14 - * The method to search documentation from. 8.15 + * The element to search documentation from. 8.16 */ 8.17 - public MethodDoc method = null; 8.18 + public ProgramElementDoc element; 8.19 /** 8.20 * The taglet to search for documentation on behalf of. Null if we want 8.21 * to search for overall documentation. 8.22 @@ -84,54 +84,55 @@ 8.23 */ 8.24 public boolean isTypeVariableParamTag = false; 8.25 8.26 - public Input() {} 8.27 - 8.28 - public Input(MethodDoc method, InheritableTaglet taglet, Tag tag, 8.29 + public Input(ProgramElementDoc element, InheritableTaglet taglet, Tag tag, 8.30 boolean isFirstSentence, boolean isInheritDocTag) { 8.31 - this.method = method; 8.32 + this(element); 8.33 this.taglet = taglet; 8.34 this.tag = tag; 8.35 this.isFirstSentence = isFirstSentence; 8.36 this.isInheritDocTag = isInheritDocTag; 8.37 } 8.38 8.39 - public Input(MethodDoc method, InheritableTaglet taglet, String tagId) { 8.40 - this.method = method; 8.41 + public Input(ProgramElementDoc element, InheritableTaglet taglet, String tagId) { 8.42 + this(element); 8.43 this.taglet = taglet; 8.44 this.tagId = tagId; 8.45 } 8.46 8.47 - public Input(MethodDoc method, InheritableTaglet taglet, String tagId, 8.48 + public Input(ProgramElementDoc element, InheritableTaglet taglet, String tagId, 8.49 boolean isTypeVariableParamTag) { 8.50 - this.method = method; 8.51 + this(element); 8.52 this.taglet = taglet; 8.53 this.tagId = tagId; 8.54 this.isTypeVariableParamTag = isTypeVariableParamTag; 8.55 } 8.56 8.57 - public Input(MethodDoc method, InheritableTaglet taglet) { 8.58 - this.method = method; 8.59 + public Input(ProgramElementDoc element, InheritableTaglet taglet) { 8.60 + this(element); 8.61 this.taglet = taglet; 8.62 } 8.63 8.64 - public Input(MethodDoc method) { 8.65 - this.method = method; 8.66 + public Input(ProgramElementDoc element) { 8.67 + if (element == null) 8.68 + throw new NullPointerException(); 8.69 + this.element = element; 8.70 } 8.71 8.72 - public Input(MethodDoc method, boolean isFirstSentence) { 8.73 - this.method = method; 8.74 + public Input(ProgramElementDoc element, boolean isFirstSentence) { 8.75 + this(element); 8.76 this.isFirstSentence = isFirstSentence; 8.77 } 8.78 8.79 public Input copy() { 8.80 - Input clone = new Input(); 8.81 - clone.method = this.method; 8.82 + Input clone = new Input(this.element); 8.83 clone.taglet = this.taglet; 8.84 clone.tagId = this.tagId; 8.85 clone.tag = this.tag; 8.86 clone.isFirstSentence = this.isFirstSentence; 8.87 clone.isInheritDocTag = this.isInheritDocTag; 8.88 clone.isTypeVariableParamTag = this.isTypeVariableParamTag; 8.89 + if (clone.element == null) 8.90 + throw new NullPointerException(); 8.91 return clone; 8.92 8.93 } 8.94 @@ -164,8 +165,8 @@ 8.95 8.96 /** 8.97 * When automatically inheriting throws tags, you sometime must inherit 8.98 - * more than one tag. For example if the method declares that it throws 8.99 - * IOException and the overidden method has throws tags for IOException and 8.100 + * more than one tag. For example if the element declares that it throws 8.101 + * IOException and the overridden element has throws tags for IOException and 8.102 * ZipException, both tags would be inherited because ZipException is a 8.103 * subclass of IOException. This subclass of DocFinder.Output allows 8.104 * multiple tag inheritence. 8.105 @@ -174,9 +175,9 @@ 8.106 } 8.107 8.108 /** 8.109 - * Search for the requested comments in the given method. If it does not 8.110 - * have comments, return documentation from the overriden method if possible. 8.111 - * If the overriden method does not exist or does not have documentation to 8.112 + * Search for the requested comments in the given element. If it does not 8.113 + * have comments, return documentation from the overriden element if possible. 8.114 + * If the overriden element does not exist or does not have documentation to 8.115 * inherit, search for documentation to inherit from implemented methods. 8.116 * 8.117 * @param input the input object used to perform the search. 8.118 @@ -186,14 +187,14 @@ 8.119 public static Output search(Input input) { 8.120 Output output = new Output(); 8.121 if (input.isInheritDocTag) { 8.122 - //Do nothing because "method" does not have any documentation. 8.123 + //Do nothing because "element" does not have any documentation. 8.124 //All it has it {@inheritDoc}. 8.125 } else if (input.taglet == null) { 8.126 //We want overall documentation. 8.127 output.inlineTags = input.isFirstSentence ? 8.128 - input.method.firstSentenceTags() : 8.129 - input.method.inlineTags(); 8.130 - output.holder = input.method; 8.131 + input.element.firstSentenceTags() : 8.132 + input.element.inlineTags(); 8.133 + output.holder = input.element; 8.134 } else { 8.135 input.taglet.inherit(input, output); 8.136 } 8.137 @@ -204,25 +205,38 @@ 8.138 output.isValidInheritDocTag = false; 8.139 Input inheritedSearchInput = input.copy(); 8.140 inheritedSearchInput.isInheritDocTag = false; 8.141 - if (input.method.overriddenMethod() != null) { 8.142 - inheritedSearchInput.method = input.method.overriddenMethod(); 8.143 - output = search(inheritedSearchInput); 8.144 - output.isValidInheritDocTag = true; 8.145 - if (output != null && output.inlineTags.length > 0) { 8.146 - return output; 8.147 + if (input.element instanceof MethodDoc) { 8.148 + MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod(); 8.149 + if (overriddenMethod != null) { 8.150 + inheritedSearchInput.element = overriddenMethod; 8.151 + output = search(inheritedSearchInput); 8.152 + output.isValidInheritDocTag = true; 8.153 + if (output.inlineTags.length > 0) { 8.154 + return output; 8.155 + } 8.156 } 8.157 - } 8.158 - //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does 8.159 - // not pass all implemented interfaces, we will use the 8.160 - // appropriate method here. 8.161 - MethodDoc[] implementedMethods = 8.162 - (new ImplementedMethods(input.method, null)).build(false); 8.163 - for (int i = 0; i < implementedMethods.length; i++) { 8.164 - inheritedSearchInput.method = implementedMethods[i]; 8.165 - output = search(inheritedSearchInput); 8.166 - output.isValidInheritDocTag = true; 8.167 - if (output != null && output.inlineTags.length > 0) { 8.168 - return output; 8.169 + //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does 8.170 + // not pass all implemented interfaces, we will use the 8.171 + // appropriate element here. 8.172 + MethodDoc[] implementedMethods = 8.173 + (new ImplementedMethods((MethodDoc) input.element, null)).build(false); 8.174 + for (int i = 0; i < implementedMethods.length; i++) { 8.175 + inheritedSearchInput.element = implementedMethods[i]; 8.176 + output = search(inheritedSearchInput); 8.177 + output.isValidInheritDocTag = true; 8.178 + if (output.inlineTags.length > 0) { 8.179 + return output; 8.180 + } 8.181 + } 8.182 + } else if (input.element instanceof ClassDoc) { 8.183 + ProgramElementDoc superclass = ((ClassDoc) input.element).superclass(); 8.184 + if (superclass != null) { 8.185 + inheritedSearchInput.element = superclass; 8.186 + output = search(inheritedSearchInput); 8.187 + output.isValidInheritDocTag = true; 8.188 + if (output.inlineTags.length > 0) { 8.189 + return output; 8.190 + } 8.191 } 8.192 } 8.193 return output;
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java Fri May 03 17:44:38 2013 -0700 9.3 @@ -0,0 +1,261 @@ 9.4 +/* 9.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 +/* 9.28 + * @test 9.29 + * @bug 8008768 9.30 + * @summary Using {@inheritDoc} in simple tag defined via -tag fails 9.31 + * @author Mike Duigou 9.32 + * @run main DocTest 9.33 + */ 9.34 + 9.35 +import java.io.*; 9.36 + 9.37 +/** 9.38 + * DocTest documentation. 9.39 + * 9.40 + * @apiNote DocTest API note. 9.41 + * @implSpec DocTest implementation spec. 9.42 + * @implNote DocTest implementation note. 9.43 + */ 9.44 +public class DocTest { 9.45 + public static void main(String... args) throws Exception { 9.46 + String[] javadoc_args = { 9.47 + "-verbose", 9.48 + "-d", "DocTest", 9.49 + "-tag", "apiNote:optcm:<em>API Note</em>", 9.50 + "-tag", "implSpec:optcm:<em>Implementation Requirements</em>:", 9.51 + "-tag", "implNote:optcm:<em>Implementation Note</em>:", 9.52 + "-package", 9.53 + new File(System.getProperty("test.src"), "DocTest.java").getPath() 9.54 + }; 9.55 + 9.56 + // javadoc does not report an exit code for an internal exception (!) 9.57 + // so monitor stderr for stack dumps. 9.58 + PrintStream prevErr = System.err; 9.59 + ByteArrayOutputStream err_baos = new ByteArrayOutputStream(); 9.60 + PrintStream err_ps = new PrintStream(err_baos); 9.61 + System.setErr(err_ps); 9.62 + 9.63 + int rc; 9.64 + try { 9.65 + rc = com.sun.tools.javadoc.Main.execute(javadoc_args); 9.66 + } finally { 9.67 + err_ps.close(); 9.68 + System.setErr(prevErr); 9.69 + } 9.70 + 9.71 + String err = err_baos.toString(); 9.72 + System.err.println(err); 9.73 + 9.74 + if (rc != 0) 9.75 + throw new Exception("javadoc exited with rc=" + rc); 9.76 + 9.77 + if (err.contains("at com.sun.")) 9.78 + throw new Exception("javadoc output contains stack trace"); 9.79 + } 9.80 + 9.81 + /** 9.82 + * DocTest() documentation. 9.83 + * 9.84 + * @apiNote DocTest() API note. 9.85 + * @implSpec DocTest() implementation spec. 9.86 + * @implNote DocTest() implementation note. 9.87 + */ 9.88 + public DocTest() { 9.89 + } 9.90 + 9.91 + /** 9.92 + * DocTest.testMethod() documentation. 9.93 + * 9.94 + * @apiNote DocTest.testMethod() API note. 9.95 + * @implSpec DocTest.testMethod() implementation spec. 9.96 + * @implNote DocTest.testMethod() implementation note. 9.97 + */ 9.98 + public void testMethod() { 9.99 + } 9.100 +} 9.101 + 9.102 +/** 9.103 + * DocTestWithTags documentation. 9.104 + * 9.105 + * @apiNote DocTestWithTags API note. 9.106 + * <pre> 9.107 + * DocTestWithTags API note code sample. 9.108 + * </pre> 9.109 + * @implSpec DocTestWithTags implementation spec. 9.110 + * <pre> 9.111 + * DocTestWithTags implementation spec code sample. 9.112 + * </pre> 9.113 + * @implNote DocTestWithTags implementation note. 9.114 + * <pre> 9.115 + * DocTestWithTags implementation note code sample. 9.116 + * </pre> 9.117 + */ 9.118 +class DocTestWithTags { 9.119 + 9.120 + /** 9.121 + * DocTestWithTags() documentation. 9.122 + * 9.123 + * @apiNote DocTestWithTags() API note. 9.124 + * <pre> 9.125 + * DocTestWithTags() API note code sample. 9.126 + * </pre> 9.127 + * @implSpec DocTestWithTags() implementation spec. 9.128 + * <pre> 9.129 + * DocTestWithTags() implementation spec code sample. 9.130 + * </pre> 9.131 + * @implNote DocTest() implementation note. 9.132 + * <pre> 9.133 + * DocTest() implementation note code sample. 9.134 + * </pre> 9.135 + */ 9.136 + public DocTestWithTags() { 9.137 + } 9.138 + 9.139 + /** 9.140 + * DocTest.testMethod() documentation. 9.141 + * 9.142 + * @apiNote DocTestWithTags.testMethod() API note. 9.143 + * <pre> 9.144 + * DocTestWithTags.testMethod() API note code sample. 9.145 + * </pre> 9.146 + * @implSpec DocTestWithTags.testMethod() implementation spec. 9.147 + * <pre> 9.148 + * DocTestWithTags.testMethod() API implementation spec code sample. 9.149 + * </pre> 9.150 + * @implNote DocTest.testMethod() implementation note. 9.151 + * <pre> 9.152 + * DocTest.testMethod() API implementation code sample. 9.153 + * </pre> 9.154 + */ 9.155 + public void testMethod() { 9.156 + } 9.157 +} 9.158 + 9.159 +class MinimallyExtendsDocTest extends DocTest { 9.160 +} 9.161 + 9.162 +/** 9.163 + * SimpleExtendsDocTest documentation. 9.164 + */ 9.165 +class SimpleExtendsDocTest extends DocTest { 9.166 + 9.167 + /** 9.168 + * SimpleExtendsDocTest() documentation. 9.169 + */ 9.170 + public SimpleExtendsDocTest() { 9.171 + 9.172 + } 9.173 + 9.174 + /** 9.175 + * SimpleExtendsDocTest.testMethod() documenation. 9.176 + */ 9.177 + @java.lang.Override 9.178 + public void testMethod() { 9.179 + } 9.180 +} 9.181 + 9.182 +/** 9.183 + * {@inheritDoc} 9.184 + */ 9.185 +class SimpleInheritDocDocTest extends DocTest { 9.186 + 9.187 + /** 9.188 + * {@inheritDoc} 9.189 + */ 9.190 + public SimpleInheritDocDocTest() { 9.191 + } 9.192 + 9.193 + /** 9.194 + * {@inheritDoc} 9.195 + */ 9.196 + @java.lang.Override 9.197 + public void testMethod() { 9.198 + } 9.199 +} 9.200 + 9.201 +/** 9.202 + * {@inheritDoc} 9.203 + * 9.204 + * @apiNote {@inheritDoc} 9.205 + * @implSpec {@inheritDoc} 9.206 + * @implNote {@inheritDoc} 9.207 + */ 9.208 +class FullInheritDocDocTest extends DocTest { 9.209 + 9.210 + /** 9.211 + * {@inheritDoc} 9.212 + * 9.213 + * @apiNote {@inheritDoc} 9.214 + * @implSpec {@inheritDoc} 9.215 + * @implNote {@inheritDoc} 9.216 + */ 9.217 + public FullInheritDocDocTest() { 9.218 + 9.219 + } 9.220 + 9.221 + /** 9.222 + * {@inheritDoc} 9.223 + * 9.224 + * @apiNote {@inheritDoc} 9.225 + * @implSpec {@inheritDoc} 9.226 + * @implNote {@inheritDoc} 9.227 + */ 9.228 + @java.lang.Override 9.229 + public void testMethod() { 9.230 + } 9.231 +} 9.232 + 9.233 +/** 9.234 + * {@inheritDoc} and FullInheritDocPlusDocTest documentation. 9.235 + * 9.236 + * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest API note. 9.237 + * @implNote {@inheritDoc} and FullInheritDocPlusDocTest implementation specification. 9.238 + * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest implementation note. 9.239 + */ 9.240 +class FullInheritDocPlusDocTest extends DocTest { 9.241 + 9.242 + /** 9.243 + * {@inheritDoc} and FullInheritDocPlusDocTest() documentation. 9.244 + * 9.245 + * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest() API note. 9.246 + * @implNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation specification. 9.247 + * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation note. 9.248 + */ 9.249 + public FullInheritDocPlusDocTest() { 9.250 + 9.251 + } 9.252 + 9.253 + /** 9.254 + * {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() documentation. 9.255 + * 9.256 + * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() API note. 9.257 + * @implNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation specification. 9.258 + * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation note. 9.259 + */ 9.260 + @java.lang.Override 9.261 + public void testMethod() { 9.262 + } 9.263 +} 9.264 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java Fri May 03 17:44:38 2013 -0700 10.3 @@ -0,0 +1,80 @@ 10.4 +/* 10.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 8008768 10.30 + * @summary Using {@inheritDoc} in simple tag defined via -tag fails 10.31 + * @library ../lib/ 10.32 + * @build JavadocTester TestSimpleTagInherit 10.33 + * @run main TestSimpleTagInherit 10.34 + */ 10.35 + 10.36 +public class TestSimpleTagInherit extends JavadocTester { 10.37 + 10.38 + //Test information. 10.39 + private static final String BUG_ID = "8008768"; 10.40 + private static final String OUTPUT_DIR = BUG_ID; 10.41 + 10.42 + //Javadoc arguments. 10.43 + private static final String[] ARGS = new String[] { 10.44 + "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, 10.45 + "-tag", "custom:optcm:<em>Custom:</em>", 10.46 + "p" 10.47 + }; 10.48 + 10.49 + //Input for string search tests. 10.50 + private static final String[][] TEST = { 10.51 + { BUG_ID + FS + "p" + FS + "TestClass.html", 10.52 + "<dt><span class=\"strong\"><em>Custom:</em></span></dt>" + NL + 10.53 + " <dd>doc for BaseClass class</dd>" }, 10.54 + { BUG_ID + FS + "p" + FS + "TestClass.html", 10.55 + "<dt><span class=\"strong\"><em>Custom:</em></span></dt>" + NL + 10.56 + " <dd>doc for BaseClass method</dd>" } 10.57 + }; 10.58 + private static final String[][] NEGATED_TEST = NO_TEST; 10.59 + 10.60 + /** 10.61 + * The entry point of the test. 10.62 + * @param args the array of command line arguments. 10.63 + */ 10.64 + public static void main(String[] args) { 10.65 + TestSimpleTagInherit tester = new TestSimpleTagInherit(); 10.66 + run(tester, ARGS, TEST, NEGATED_TEST); 10.67 + tester.printSummary(); 10.68 + } 10.69 + 10.70 + /** 10.71 + * {@inheritDoc} 10.72 + */ 10.73 + public String getBugId() { 10.74 + return BUG_ID; 10.75 + } 10.76 + 10.77 + /** 10.78 + * {@inheritDoc} 10.79 + */ 10.80 + public String getBugName() { 10.81 + return getClass().getName(); 10.82 + } 10.83 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/com/sun/javadoc/testSimpleTagInherit/p/BaseClass.java Fri May 03 17:44:38 2013 -0700 11.3 @@ -0,0 +1,34 @@ 11.4 +/* 11.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +package p; 11.28 + 11.29 +/** 11.30 + * @custom doc for BaseClass class 11.31 + */ 11.32 +public class BaseClass { 11.33 + /** 11.34 + * @custom doc for BaseClass method 11.35 + */ 11.36 + public void m() { } 11.37 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/com/sun/javadoc/testSimpleTagInherit/p/TestClass.java Fri May 03 17:44:38 2013 -0700 12.3 @@ -0,0 +1,34 @@ 12.4 +/* 12.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +package p; 12.28 + 12.29 +/** 12.30 + * @custom {@inheritDoc} 12.31 + */ 12.32 +public class TestClass extends BaseClass { 12.33 + /** 12.34 + * @custom {@inheritDoc} 12.35 + */ 12.36 + public void m() { } 12.37 +}