8150130: NPE building javafx docs with new doclet

Reviewed-by: jjg
This commit is contained in:
Kumar Srinivasan 2016-03-03 14:54:44 -08:00
parent da3426846d
commit daa39fa665
3 changed files with 92 additions and 3 deletions

View File

@ -50,6 +50,7 @@ import com.sun.tools.javac.api.JavacTrees;
import com.sun.tools.javac.parser.ParserFactory;
import com.sun.tools.javac.parser.ReferenceParser;
import com.sun.tools.javac.parser.Tokens.Comment;
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
import com.sun.tools.javac.tree.DCTree.DCAttribute;
import com.sun.tools.javac.tree.DCTree.DCAuthor;
import com.sun.tools.javac.tree.DCTree.DCComment;
@ -206,7 +207,31 @@ public class DocTreeMaker implements DocTreeFactory {
lb.addAll(cast(firstSentence));
lb.addAll(cast(body));
List<DCTree> fullBody = lb.toList();
DCDocComment tree = new DCDocComment(null, fullBody, cast(firstSentence), cast(body), cast(tags));
// A dummy comment to keep the diagnostics logic happy.
Comment c = new Comment() {
@Override
public String getText() {
return null;
}
@Override
public int getSourcePos(int index) {
return Position.NOPOS;
}
@Override
public CommentStyle getStyle() {
return CommentStyle.JAVADOC;
}
@Override
public boolean isDeprecated() {
return false;
}
};
DCDocComment tree = new DCDocComment(c, fullBody, cast(firstSentence), cast(body), cast(tags));
return tree;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 7112427 8012295 8025633 8026567 8061305 8081854
* @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130
* @summary Test of the JavaFX doclet features.
* @author jvalenta
* @library ../lib
@ -137,6 +137,7 @@ public class TestJavaFX extends JavadocTester {
+ "</ul>\n"
+ "</li>");
}
/*
* Test without -javafx option, to ensure property getters and setters
* are treated just like any other java method.
@ -181,4 +182,22 @@ public class TestJavaFX extends JavadocTester {
+ "</span>()</code>&nbsp;</td>"
);
}
/*
* Force the doclet to emit a warning when processing a synthesized,
* DocComment, and ensure that the run succeeds.
*/
@Test
void test4() {
javadoc("-d", "out4",
"-javafx",
"-Xdoclint:none",
"-sourcepath", testSrc,
"-package",
"pkg4");
checkExit(Exit.OK);
// make sure the doclet indeed emits the warning
checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag >");
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg4;
public class C {
/**
* Defines the number of cycles in this animation. The {@code cycleCount}
* may be {@code INDEFINITE} for animations that repeat indefinitely.
* Now we add a > to deliberately cause an Html error.
* @defaultValue 11
* @since JavaFX 8.0
*/
public DoubleProperty rate;
public final void setRate(double value) {}
public final double getRate() {return 2.0d;}
public final DoubleProperty rateProperty() {return new DoubleProperty();}
class DoubleProperty {}
}