Skip to content
Permalink
Browse files
8268582: javadoc throws NPE with --ignore-source-errors option
Reviewed-by: jjg
  • Loading branch information
hns committed Dec 1, 2021
1 parent f41e768 commit 0dfb3a705d2ad0ce4ac0f7dd18fb65d7ae735f16
Showing 2 changed files with 21 additions and 5 deletions.
@@ -2893,8 +2893,11 @@ public enum DeclarationPreviewLanguageFeatures {
}

public PreviewSummary declaredUsingPreviewAPIs(Element el) {
List<TypeElement> usedInDeclaration = new ArrayList<>();
usedInDeclaration.addAll(annotations2Classes(el));
if (el.asType().getKind() == ERROR) {
// Can happen with undocumented --ignore-source-errors option
return new PreviewSummary(Collections.emptySet(), Collections.emptySet(), Collections.emptySet());
}
List<TypeElement> usedInDeclaration = new ArrayList<>(annotations2Classes(el));
switch (el.getKind()) {
case ANNOTATION_TYPE, CLASS, ENUM, INTERFACE, RECORD -> {
TypeElement te = (TypeElement) el;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@@ -23,7 +23,7 @@

/*
* @test
* @bug 8175219
* @bug 8175219 8268582
* @summary test --ignore-errors works correctly
* @modules
* jdk.javadoc/jdk.javadoc.internal.api
@@ -73,6 +73,12 @@ public void runIgnoreErrorsOffByDefault() throws Exception {
if (!out.contains("modifier static not allowed here")) {
throw new Exception("expected string not found \'modifier static not allowed here\'");
}
if (!out.contains("package invalid.example does not exist")) {
throw new Exception("expected string not found \'package invalid.example does not exist\'");
}
if (!out.contains("cannot find symbol")) {
throw new Exception("expected string not found \'cannot find symbol\'");
}
}

@Test
@@ -84,12 +90,19 @@ public void runIgnoreErrorsOn() throws Exception {
if (!out.contains("modifier static not allowed here")) {
throw new Exception("expected string not found \'modifier static not allowed here\'");
}
if (!out.contains("package invalid.example does not exist")) {
throw new Exception("expected string not found \'package invalid.example does not exist\'");
}
if (!out.contains("cannot find symbol")) {
throw new Exception("expected string not found \'cannot find symbol\'");
}
}

void emitSample(Path file) throws IOException {
String[] contents = {
"/** A java file with errors */",
"public static class Foo {}"
"import invalid.example.OtherClass;",
"public static class Foo<T> extends OtherClass<T> {}"
};
Files.write(file, Arrays.asList(contents), StandardOpenOption.CREATE);
}

1 comment on commit 0dfb3a7

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 0dfb3a7 Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.