# HG changeset patch # User ksrini # Date 1487186632 28800 # Node ID cdf2965de35bf32b751b25f0a7d4759ae7bb5ddb # Parent 9d40b4d77b7f135188badecb1f39c8eda93e1e42 8173804: javadoc throws UnsupportedOperationException: should not happen Reviewed-by: jjg diff -r 9d40b4d77b7f -r cdf2965de35b langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Wed Feb 15 09:50:26 2017 -0800 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java Wed Feb 15 11:23:52 2017 -0800 @@ -1886,11 +1886,6 @@ } @Override - public String visitPrimitive(PrimitiveType t, Void p) { - return t.toString(); - } - - @Override public String visitTypeVariable(javax.lang.model.type.TypeVariable t, Void p) { // The knee jerk reaction is to do this but don't!, as we would like // it to be compatible with the old world, now if we decide to do so @@ -1900,9 +1895,10 @@ } @Override - protected String defaultAction(TypeMirror e, Void p) { - throw new UnsupportedOperationException("should not happen"); + protected String defaultAction(TypeMirror t, Void p) { + return t.toString(); } + }.visit(t); } diff -r 9d40b4d77b7f -r cdf2965de35b langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testMissingType/TestMissingType.java Wed Feb 15 11:23:52 2017 -0800 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017, 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. + */ + +/* + * @test + * @bug 8173804 + * @summary make sure doclet can handle missing types + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestMissingType + */ + +public class TestMissingType extends JavadocTester { + + public static void main(String... args) throws Exception { + TestMissingType tester = new TestMissingType(); + tester.runTests(); + } + + @Test + void test() { + javadoc("-d", "out", + "-use", + "-sourcepath", testSrc, + "p"); + checkExit(Exit.OK); + checkFiles(true, "p/class-use/MissingType.html"); + } +} diff -r 9d40b4d77b7f -r cdf2965de35b langtools/test/jdk/javadoc/doclet/testMissingType/p/MissingType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testMissingType/p/MissingType.java Wed Feb 15 11:23:52 2017 -0800 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017, 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 p; + +public final class MissingType { + /** + * Do something with a missing type. + * + * @param out use the missing type + */ + public void encode(MissingMe out) {} +}