Skip to content
Permalink
Browse files
8266082: AssertionError in Annotate.fromAnnotations with -Xdoclint
Reviewed-by: vromero
  • Loading branch information
Joel Borggrén-Franck committed Jun 21, 2021
1 parent b7d78a5 commit 0b8a0e2b58dbdd5c9553e502212d32c033a5efb5
@@ -25,6 +25,9 @@

package com.sun.tools.javac.parser;

import com.sun.source.tree.AnnotatedTypeTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.TreeScanner;
import com.sun.tools.javac.parser.Tokens.TokenKind;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.List;
@@ -193,6 +196,21 @@ private Name parseMember(String s) throws ParseException {
if (p.token().kind != TokenKind.EOF)
throw new ParseException("dc.ref.unexpected.input");

if (new TypeAnnotationFinder().scan(paramTypes, null) != null)
throw new ParseException("dc.ref.annotations.not.allowed");

return paramTypes.toList();
}
}

static class TypeAnnotationFinder extends TreeScanner<Tree, Void> {
@Override
public Tree visitAnnotatedType(AnnotatedTypeTree t, Void ignore) {
return t;
}

@Override
public Tree reduce(Tree t1, Tree t2) {
return t1 != null ? t1 : t2;
}
}
}
@@ -3266,6 +3266,9 @@ compiler.err.dc.unterminated.signature=\
compiler.err.dc.unterminated.string=\
unterminated string

compiler.err.dc.ref.annotations.not.allowed=\
annotations not allowed

###
# errors related to modules

@@ -0,0 +1,31 @@
/*
* @test /nodynamiccopyright/
* @bug 8266082
* @summary javac should not crash when seeing type annotations in links
* @compile/fail/ref=CrashInAnnotateTest.out -Xdoclint -XDrawDiagnostics CrashInAnnotateTest.java
*/

import java.util.List;

/** {@link #equals(@Deprecated Object)}
* {@link java.util.Map.@Deprecated Entry#getKey()}
*/
class CrashInAnnotateTest {
}

/** {@link #compare(Object, List<List<@Deprecated Object>>)} */
class CrashInAnnotateTest2 {
void compare(Object o, List<List<Object>> l) {}
}

/** {@link @Deprecated java.lang.Object#hashCode()} */
class CrashInAnnotateTest3 { }

/** {@link CrashInAnnotateTest4.@java.lang.Deprecated Inner#aField}
* {@link java.util.Map.@Deprecated#getKey()}
*/
class CrashInAnnotateTest4 {
class Inner {
Object aField;
}
}
@@ -0,0 +1,11 @@
CrashInAnnotateTest.java:10:5: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:11:5: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:16:5: compiler.err.proc.messager: annotations not allowed
CrashInAnnotateTest.java:18:10: compiler.warn.proc.messager: no comment
CrashInAnnotateTest.java:21:5: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:24:5: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:25:5: compiler.err.proc.messager: syntax error in reference
CrashInAnnotateTest.java:28:5: compiler.warn.proc.messager: no comment
CrashInAnnotateTest.java:29:16: compiler.warn.proc.messager: no comment
6 errors
3 warnings
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2021, 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.
*/

// key: compiler.err.dc.ref.annotations.not.allowed
// key: compiler.note.note
// key: compiler.note.proc.messager
// run: backdoor
// options: -processor DocCommentProcessor -proc:only

/** {@link #equals(@Deprecated Object)} */
class NoAnnotationsInLink {
}

1 comment on commit 0b8a0e2

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 0b8a0e2 Jun 21, 2021

Please sign in to comment.