8061305: Javadoc crashes when method name ends with "Property"

Tue, 19 Jun 2018 12:03:35 +0200

author
sgehwolf
date
Tue, 19 Jun 2018 12:03:35 +0200
changeset 3640
12470d69d5ae
parent 3638
db3c95ad8335
child 3641
a0081a63abee

8061305: Javadoc crashes when method name ends with "Property"
Reviewed-by: jjg

src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testMethodEndingInProperty/Test.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testMethodEndingInProperty/TestMethodEndingInProperty.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java	Fri Apr 13 18:20:32 2018 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java	Tue Jun 19 12:03:35 2018 +0200
     1.3 @@ -664,6 +664,9 @@
     1.4          // properties aren't named setA* or getA*
     1.5          private final Pattern pattern = Pattern.compile("[sg]et\\p{Upper}.*");
     1.6          private boolean isPropertyMethod(MethodDoc method) {
     1.7 +            if (!configuration.javafx) {
     1.8 +               return false;
     1.9 +            }
    1.10              if (!method.name().endsWith("Property")) {
    1.11                  return false;
    1.12              }
    1.13 @@ -675,7 +678,9 @@
    1.14              if (pattern.matcher(method.name()).matches()) {
    1.15                  return false;
    1.16              }
    1.17 -
    1.18 +            if (method.typeParameters().length > 0) {
    1.19 +                return false;
    1.20 +            }
    1.21              return 0 == method.parameters().length
    1.22                      && !"void".equals(method.returnType().simpleTypeName());
    1.23          }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/com/sun/javadoc/testMethodEndingInProperty/Test.java	Tue Jun 19 12:03:35 2018 +0200
     2.3 @@ -0,0 +1,26 @@
     2.4 +/*
     2.5 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +public class Test {
    2.28 +    public <T> Object fProperty() { return null; }
    2.29 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/com/sun/javadoc/testMethodEndingInProperty/TestMethodEndingInProperty.java	Tue Jun 19 12:03:35 2018 +0200
     3.3 @@ -0,0 +1,73 @@
     3.4 +/*
     3.5 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 8061305
    3.30 + * @summary Test methods ending in 'Property'
    3.31 + * @library ../lib/
    3.32 + * @build JavadocTester TestMethodEndingInProperty
    3.33 + * @run main TestMethodEndingInProperty
    3.34 + */
    3.35 +
    3.36 +public class TestMethodEndingInProperty extends JavadocTester {
    3.37 +
    3.38 +    private static final String BUG_ID = "8061305";
    3.39 +    private static final String ERROR_OUTPUT = "com.sun.tools.doclets.formats.html.PropertyWriterImpl " +
    3.40 +                                               "cannot be cast to " +
    3.41 +                                               "com.sun.tools.doclets.formats.html.AbstractExecutableMemberWriter";
    3.42 +
    3.43 +    private static final String[] ARGS = new String[] {
    3.44 +        "-d", BUG_ID, "-sourcepath", SRC_DIR, SRC_DIR + FS + "Test.java"
    3.45 +    };
    3.46 +
    3.47 +    /**
    3.48 +     * The entry point of the test.
    3.49 +     * @param args the array of command line arguments.
    3.50 +     */
    3.51 +    public static void main(String[] args) {
    3.52 +        TestMethodEndingInProperty tester = new TestMethodEndingInProperty();
    3.53 +        int actual = tester.runJavadoc(ARGS);
    3.54 +        int expected = 0;
    3.55 +        tester.checkExitCode(expected, actual);
    3.56 +        String errOut = tester.getErrorOutput();
    3.57 +        if (errOut.contains(ERROR_OUTPUT)) {
    3.58 +            throw new Error("Error output contained: " + ERROR_OUTPUT);
    3.59 +        }
    3.60 +        System.out.println("Test passed");
    3.61 +    }
    3.62 +
    3.63 +    /**
    3.64 +     * {@inheritDoc}
    3.65 +     */
    3.66 +    public String getBugId() {
    3.67 +        return BUG_ID;
    3.68 +    }
    3.69 +
    3.70 +    /**
    3.71 +     * {@inheritDoc}
    3.72 +     */
    3.73 +    public String getBugName() {
    3.74 +        return getClass().getName();
    3.75 +    }
    3.76 +}

mercurial