RFR: 8225003: NPE in Attr.attribIdentAsEnumType

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8225003: NPE in Attr.attribIdentAsEnumType

Guoxiong Li-2
Hi all,

`Attr.attribIdentAsEnumType` uses `enclClass` which would return null if some error types and/or error symbols exist.

And if we use annotation processor, some errors would be reported to `deferredDiagnosticHandler` and not immediately reported to the users. At this time, the `NullPointerException`(NPE) occurs and all the other work, including that the `deferredDiagnosticHandler` report the errors to users, would not be done. So the user would see the NPE and see that the compiler crashes.

In other words, the NPE also occurs without the annotation processor. But because the `deferredDiagnosticHandler` is not set without the annotation processor, some other errors would be shown immediately to users and the NPE is not shown when using [these catch code](https://github.com/openjdk/jdk/blob/0849117d5c3a9ae12231262fc0d3366a6e8a458d/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java#L349).

This patch fixes the NPE and reports the deferred diagnostics to users at the end of the compilation task. Maybe you can consider that this patch solves two bugs:

1. [JDK-8225003 NPE in Attr.attribIdentAsEnumType](https://bugs.openjdk.java.net/browse/JDK-8225003)
2. Some deferred diagnostics would be not reported to user when the compiler crashes.

The test case needs to fix these two bugs to pass, so I put them together.

Thank you for taking the time to review.

Best Regards.

-------------

Commit messages:
 - 8225003: NPE in Attr.attribIdentAsEnumType

Changes: https://git.openjdk.java.net/jdk/pull/1864/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1864&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8225003
  Stats: 111 lines in 3 files changed: 107 ins; 1 del; 3 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1864.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1864/head:pull/1864

PR: https://git.openjdk.java.net/jdk/pull/1864
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8225003: NPE in Attr.attribIdentAsEnumType [v2]

Guoxiong Li-2
> Hi all,
>
> `Attr.attribIdentAsEnumType` uses `enclClass` which would return null if some error types and/or error symbols exist.
>
> And if we use annotation processor, some errors would be reported to `deferredDiagnosticHandler` and not immediately reported to the users. At this time, the `NullPointerException`(NPE) occurs and all the other work, including that the `deferredDiagnosticHandler` report the errors to users, would not be done. So the user would see the NPE and see that the compiler crashes.
>
> In other words, the NPE also occurs without the annotation processor. But because the `deferredDiagnosticHandler` is not set without the annotation processor, some other errors would be shown immediately to users and the NPE is not shown when using [these catch code](https://github.com/openjdk/jdk/blob/0849117d5c3a9ae12231262fc0d3366a6e8a458d/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java#L349).
>
> This patch fixes the NPE and reports the deferred diagnostics to users at the end of the compilation task. Maybe you can consider that this patch solves two bugs:
>
> 1. [JDK-8225003 NPE in Attr.attribIdentAsEnumType](https://bugs.openjdk.java.net/browse/JDK-8225003)
> 2. Some deferred diagnostics would be not reported to user when the compiler crashes.
>
> The test case needs to fix these two bugs to pass, so I put them together.
>
> Thank you for taking the time to review.
>
> Best Regards.

Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:

  Modify legal header.

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/1864/files
  - new: https://git.openjdk.java.net/jdk/pull/1864/files/9c3a3d0a..4b085238

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=1864&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=1864&range=00-01

  Stats: 3 lines in 1 file changed: 0 ins; 2 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1864.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1864/head:pull/1864

PR: https://git.openjdk.java.net/jdk/pull/1864
Reply | Threaded
Open this post in threaded view
|

Withdrawn: 8225003: NPE in Attr.attribIdentAsEnumType

duke
In reply to this post by Guoxiong Li-2
On Tue, 22 Dec 2020 15:25:08 GMT, Guoxiong Li <[hidden email]> wrote:

> Hi all,
>
> `Attr.attribIdentAsEnumType` uses `enclClass` which would return null if some error types and/or error symbols exist.
>
> And if we use annotation processor, some errors would be reported to `deferredDiagnosticHandler` and not immediately reported to the users. At this time, the `NullPointerException`(NPE) occurs and all the other work, including that the `deferredDiagnosticHandler` report the errors to users, would not be done. So the user would see the NPE and see that the compiler crashes.
>
> In other words, the NPE also occurs without the annotation processor. But because the `deferredDiagnosticHandler` is not set without the annotation processor, some other errors would be shown immediately to users and the NPE is not shown when using [these catch code](https://github.com/openjdk/jdk/blob/0849117d5c3a9ae12231262fc0d3366a6e8a458d/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java#L349).
>
> This patch fixes the NPE and reports the deferred diagnostics to users at the end of the compilation task. Maybe you can consider that this patch solves two bugs:
>
> 1. [JDK-8225003 NPE in Attr.attribIdentAsEnumType](https://bugs.openjdk.java.net/browse/JDK-8225003)
> 2. Some deferred diagnostics would be not reported to user when the compiler crashes.
>
> The test case needs to fix these two bugs to pass, so I put them together.
>
> Thank you for taking the time to review.
>
> Best Regards.

This pull request has been closed without being integrated.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1864