Repository: checkstyle/checkstyle

Problem statement:
NPE in IllegalTypeCheck when checking a record (Java 14)
Hello,

https://checkstyle.org/config_coding.html#IllegalType

I'm trying JDK 16 with language-level 16 I've run into an NPE. I've discovered this on Checkstyle 9.0, but the same problem is still unresolved on the `master` branch.

Since the build is configured to run on `1.8`, I had to modify the source+target language to allow for the reproducer test-case, which I've prepared here: https://github.com/fprochazka/checkstyle/commit/0e18223a4fd8e91cb3264fd970573f0e6e1c0a5d, it's probably not ideal, but IMHO it should pass a verifiable reproducer.

if you run the `IllegalTypeCheckTest` from my commit, you'll see the following errors: 

<details>
 <summary>InputIllegalTypeTestRecordsPass fail</summary>

```
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing /home/fprochazka/devel/libs/checkstyle/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeTestRecordsPass.java

	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:302)
	at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:221)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.getActualViolationsForFile(AbstractModuleTestSupport.java:442)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.verifyViolations(AbstractModuleTestSupport.java:416)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.verifyWithInlineConfigParser(AbstractModuleTestSupport.java:269)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheckTest.testValidateRecordsPass(IllegalTypeCheckTest.java:66)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.NullPointerException: Cannot invoke "com.puppycrawl.tools.checkstyle.api.DetailAST.getFirstChild()" because "modifiers" is null
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isContainVerifiableType(IllegalTypeCheck.java:516)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isVerifiable(IllegalTypeCheck.java:502)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitVariableDef(IllegalTypeCheck.java:577)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitToken(IllegalTypeCheck.java:477)
	at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:335)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:406)
	at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:273)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:154)
	at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:87)
	at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:328)
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:289)
	... 70 more
```

</details>


<details>
 <summary>InputIllegalTypeTestInnerRecordsPass fail</summary>

```
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing /home/fprochazka/devel/libs/checkstyle/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeTestInnerRecordsPass.java

	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:302)
	at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:221)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.getActualViolationsForFile(AbstractModuleTestSupport.java:442)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.verifyViolations(AbstractModuleTestSupport.java:416)
	at com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport.verifyWithInlineConfigParser(AbstractModuleTestSupport.java:269)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheckTest.testValidateInnerRecordsPass(IllegalTypeCheckTest.java:74)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.NullPointerException: Cannot invoke "com.puppycrawl.tools.checkstyle.api.DetailAST.getFirstChild()" because "modifiers" is null
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isContainVerifiableType(IllegalTypeCheck.java:516)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isVerifiable(IllegalTypeCheck.java:502)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitVariableDef(IllegalTypeCheck.java:577)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitToken(IllegalTypeCheck.java:477)
	at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:335)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:406)
	at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:273)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:154)
	at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:87)
	at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:328)
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:289)
	... 70 more
```

</details>



The interesting part is IMHO this: 

```
java.lang.NullPointerException: Cannot invoke "com.puppycrawl.tools.checkstyle.api.DetailAST.getFirstChild()" because "modifiers" is null
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isContainVerifiableType(IllegalTypeCheck.java:516)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isVerifiable(IllegalTypeCheck.java:502)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitVariableDef(IllegalTypeCheck.java:577)
	at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitToken(IllegalTypeCheck.java:477)
	at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:335)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:406)
	at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:273)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:154)
	at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:87)
	at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:328)
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:289)
```

My configuration of the check is baked into the comment in the tested source file.

If I change

```
memberModifiers = LITERAL_PUBLIC, LITERAL_PROTECTED, LITERAL_STATIC
```

to 

```
memberModifiers = (default)
```

it starts to pass

...

Am I configuring it incorrectly? IMHO it should not throw an NPE even when configured incorrectly. 


Hints:
>  fprochazka@0e18223
> NullPointerException

I'm sorry, I am not clearly following the issue from just reading this. From your commit, which input file causes the exception?

The simplest way to report and reproduce an issue is exactly like https://checkstyle.org/report_issue.html#How_to_report_a_bug.3F .
Both `InputIllegalTypeTestInnerRecordsPass` and `InputIllegalTypeTestRecordsPass` 
Reproducable issue:

````
$ cat TestClass.java
package com.puppycrawl.tools.checkstyle.checks.coding.illegaltype;

import javax.annotation.Nullable;
import java.util.*;

public class InputIllegalTypeTestInnerRecordsPass
{

    public record IdentifiersPair(
        UUID productId,
        @Nullable String identifier
    )
    {

    }

}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
<module name="IllegalType">
  <property name="memberModifiers" value="LITERAL_PUBLIC, LITERAL_PROTECTED, LITERAL_STATIC" />
</module>
    </module>
</module>

$ java -jar checkstyle-9.0-all.jar -c TestConfig.xml TestClass.java
Starting audit...
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing TestClass.java
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:302)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:221)
    at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:409)
    at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:332)
    at com.puppycrawl.tools.checkstyle.Main.execute(Main.java:191)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:126)
Caused by: java.lang.NullPointerException
    at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isContainVerifiableType(IllegalTypeCheck.java:516)
    at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.isVerifiable(IllegalTypeCheck.java:502)
    at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitVariableDef(IllegalTypeCheck.java:577)
    at com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.visitToken(IllegalTypeCheck.java:477)
    at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:335)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:406)
    at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:273)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:154)
    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:87)
    at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:328)
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:289)
    ... 5 more
Checkstyle ends with 1 errors.
````

I'm happy to try to fix this, but I have no idea where to even begin. How do you test Java 16 features, when the build forces Java 8 in the maven build?  
> 
> 
> I'm happy to try to fix this, but I have no idea where to even begin. How do you test Java 16 features, when the build forces Java 8 in the maven build?

inputs for java version > 8 have to be placed in specific folder and have comment like
https://github.com/checkstyle/checkstyle/blob/e43c5b84acc8dae1141ed0cd3aeaeda1ff8cea23/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/naming/typename/InputTypeNameRecords.java#L13

you can check existing checks for records as an example (e.g. RecordComponentNumberCheck), they all have inputs for java14

Good place to start is TDD approach, you can first extend existing tests with your case, and then debug it to specific point in code with the problem.
Thanks, that helped! Now I have a nice reproducer in tests https://github.com/fprochazka/checkstyle/commit/7fa92879f7a382abf04ead31c69297c4bb5d97a2 

I've tried debugging to see if it's something simple...

![image](https://user-images.githubusercontent.com/158625/134563625-1d57f5a1-1f81-4f29-86e7-756304e20dca.png)

Now I'm thinking that [record components don't have visibility modifiers at all](https://openjdk.java.net/jeps/359) and maybe the filtering should not apply (all members will have public accessors)
-> https://github.com/checkstyle/checkstyle/pull/10820 
![Untitled](https://user-images.githubusercontent.com/71710042/140963345-c36dcfd0-6365-4103-8610-20f5f8cbddec.png)
I am getting this error: `java.lang.StringIndexOutOfBoundsException: begin 73, end -1, length 186`

I really don't have any idea of how to resolve this.


There is some problem with header comment in Input file related to Fully qualified name of Check, make sure it is spelled properly.
Recheck other Input files to see difference and spot a problem.
Complex exception is partially due to https://github.com/checkstyle/checkstyle/pull/10766 being incomplete. @romani It is waiting on your review.
@Rahulkhinchi03, referenced PR is merged, please rebase on latest code.
@romani I am really sorry @romani I have my end-semester exams going on. Kindly give me some days to resolve the issues.

Patch:
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheck.java
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheck.java
@@ -111,7 +111,7 @@
  * <li>
  * Property {@code memberModifiers} - Control whether to check only methods and fields with any
  * of the specified modifiers.
- * This property does not affect method calls nor method references.
+ * This property does not affect method calls nor method references nor record components.
  * Type is {@code java.lang.String[]}.
  * Validation type is {@code tokenTypesSet}.
  * Default value is {@code ""}.
@@ -380,7 +380,7 @@ public final class IllegalTypeCheck extends AbstractCheck {
     private final Set<String> ignoredMethodNames = new HashSet<>();
     /**
      * Control whether to check only methods and fields with any of the specified modifiers.
-     * This property does not affect method calls nor method references.
+     * This property does not affect method calls nor method references nor record components.
      */
     private List<Integer> memberModifiers = Collections.emptyList();
 
@@ -473,9 +473,11 @@ public void visitToken(DetailAST ast) {
             case TokenTypes.VARIABLE_DEF:
             case TokenTypes.ANNOTATION_FIELD_DEF:
             case TokenTypes.PATTERN_VARIABLE_DEF:
-            case TokenTypes.RECORD_COMPONENT_DEF:
                 visitVariableDef(ast);
                 break;
+            case TokenTypes.RECORD_COMPONENT_DEF:
+                checkClassName(ast);
+                break;
             case TokenTypes.PARAMETER_DEF:
                 visitParameterDef(ast);
                 break;
@@ -852,7 +854,7 @@ public void setLegalAbstractClassNames(String... classNames) {
     /**
      * Setter to control whether to check only methods and fields with any of
      * the specified modifiers.
-     * This property does not affect method calls nor method references.
+     * This property does not affect method calls nor method references nor record components.
      *
      * @param modifiers String contains modifiers.
      */


Test patch:
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java
@@ -340,6 +340,56 @@ public void testIllegalTypeNewArrayStructure() throws Exception {
             expected);
     }
 
+    @Test
+    public void testRecordComponentsDefault() throws Exception {
+        final String[] expected = {
+            "45:9: " + getCheckMessage(MSG_KEY, "HashSet"),
+            "53:23: " + getCheckMessage(MSG_KEY, "HashSet"),
+        };
+
+        verifyWithInlineConfigParser(
+                getNonCompilablePath(
+                        "InputIllegalTypeRecordsWithMemberModifiersDefault.java"),
+                expected);
+    }
+
+    @Test
+    public void testRecordComponentsFinal() throws Exception {
+        final String[] expected = {
+            "45:9: " + getCheckMessage(MSG_KEY, "HashSet"),
+            "53:23: " + getCheckMessage(MSG_KEY, "HashSet"),
+        };
+
+        verifyWithInlineConfigParser(
+                getNonCompilablePath(
+                        "InputIllegalTypeRecordsWithMemberModifiersFinal.java"),
+                expected);
+    }
+
+    @Test
+    public void testRecordComponentsPrivateFinal() throws Exception {
+        final String[] expected = {
+            "45:9: " + getCheckMessage(MSG_KEY, "HashSet"),
+            "53:23: " + getCheckMessage(MSG_KEY, "HashSet"),
+        };
+
+        verifyWithInlineConfigParser(
+                getNonCompilablePath(
+                        "InputIllegalTypeRecordsWithMemberModifiersPrivateFinal.java"),
+                expected);
+    }
+
+    @Test
+    public void testRecordComponentsPublicProtectedStatic() throws Exception {
+        final String[] expected = {
+            "45:9: " + getCheckMessage(MSG_KEY, "HashSet")};
+
+        verifyWithInlineConfigParser(
+                getNonCompilablePath(
+                        "InputIllegalTypeRecordsWithMemberModifiersPublicProtectedStatic.java"),
+                expected);
+    }
+
     @Test
     public void testTokensNotNull() {
         final IllegalTypeCheck check = new IllegalTypeCheck();
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersDefault.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersDefault.java
new file mode 100644
--- /dev/null
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersDefault.java
@@ -0,0 +1,63 @@
+/*
+IllegalType
+validateAbstractClassNames = (default)false
+illegalClassNames = (default)HashMap, HashSet, LinkedHashMap, LinkedHashSet, TreeMap, TreeSet, \
+                    java.util.HashMap, java.util.HashSet, java.util.LinkedHashMap, \
+                    java.util.LinkedHashSet, java.util.TreeMap, java.util.TreeSet
+legalAbstractClassNames = (default)
+ignoredMethodNames = (default)getEnvironment, getInitialContext
+illegalAbstractClassNameFormat = (default)^(.*[.])?Abstract.*$
+memberModifiers = (default)
+tokens = (default)ANNOTATION_FIELD_DEF, CLASS_DEF, INTERFACE_DEF, METHOD_CALL, METHOD_DEF, \
+         METHOD_REF, PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, \
+         RECORD_COMPONENT_DEF
+
+
+*/
+
+//non-compiled with javac: Compilable with Java14
+package com.puppycrawl.tools.checkstyle.checks.coding.illegaltype;
+
+import java.util.*;
+
+public class InputIllegalTypeRecordsWithMemberModifiersDefault
+{
+
+    public record IdentifiersPair(
+        UUID productId, // ok
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent {
+        private final UUID productId; // ok
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent(UUID productId, String identifier) {
+            this.productId = productId;
+            this.identifier = identifier;
+        }
+    }
+
+    public record IdentifiersPair2(
+        HashSet x, // violation
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent2 {
+        private final HashSet x; // violation
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent2(Set x, String identifier) { // ok
+            this.x = (HashSet) x; // ok
+            this.identifier = identifier;
+        }
+    }
+
+}
+
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersFinal.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersFinal.java
new file mode 100644
--- /dev/null
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersFinal.java
@@ -0,0 +1,62 @@
+/*
+IllegalType
+validateAbstractClassNames = (default)false
+illegalClassNames = (default)HashMap, HashSet, LinkedHashMap, LinkedHashSet, TreeMap, TreeSet, \
+                    java.util.HashMap, java.util.HashSet, java.util.LinkedHashMap, \
+                    java.util.LinkedHashSet, java.util.TreeMap, java.util.TreeSet
+legalAbstractClassNames = (default)
+ignoredMethodNames = (default)getEnvironment, getInitialContext
+illegalAbstractClassNameFormat = (default)^(.*[.])?Abstract.*$
+memberModifiers = FINAL
+tokens = (default)ANNOTATION_FIELD_DEF, CLASS_DEF, INTERFACE_DEF, METHOD_CALL, METHOD_DEF, \
+         METHOD_REF, PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, \
+         RECORD_COMPONENT_DEF
+
+
+*/
+
+//non-compiled with javac: Compilable with Java14
+package com.puppycrawl.tools.checkstyle.checks.coding.illegaltype;
+
+import java.util.*;
+
+public class InputIllegalTypeRecordsWithMemberModifiersFinal
+{
+
+    public record IdentifiersPair(
+        UUID productId, // ok
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent {
+        private final UUID productId; // ok
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent(UUID productId, String identifier) {
+            this.productId = productId;
+            this.identifier = identifier;
+        }
+    }
+
+    public record IdentifiersPair2(
+        HashSet x, // violation
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent2 {
+        private final HashSet x; // violation
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent2(Set x, String identifier) { // ok
+            this.x = (HashSet) x; // ok
+            this.identifier = identifier;
+        }
+    }
+
+}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersPrivateFinal.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersPrivateFinal.java
new file mode 100644
--- /dev/null
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersPrivateFinal.java
@@ -0,0 +1,62 @@
+/*
+IllegalType
+validateAbstractClassNames = (default)false
+illegalClassNames = (default)HashMap, HashSet, LinkedHashMap, LinkedHashSet, TreeMap, TreeSet, \
+                    java.util.HashMap, java.util.HashSet, java.util.LinkedHashMap, \
+                    java.util.LinkedHashSet, java.util.TreeMap, java.util.TreeSet
+legalAbstractClassNames = (default)
+ignoredMethodNames = (default)getEnvironment, getInitialContext
+illegalAbstractClassNameFormat = (default)^(.*[.])?Abstract.*$
+memberModifiers = LITERAL_PRIVATE, FINAL
+tokens = (default)ANNOTATION_FIELD_DEF, CLASS_DEF, INTERFACE_DEF, METHOD_CALL, METHOD_DEF, \
+         METHOD_REF, PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, \
+         RECORD_COMPONENT_DEF
+
+
+*/
+
+//non-compiled with javac: Compilable with Java14
+package com.puppycrawl.tools.checkstyle.checks.coding.illegaltype;
+
+import java.util.*;
+
+public class InputIllegalTypeRecordsWithMemberModifiersPrivateFinal
+{
+
+    public record IdentifiersPair(
+        UUID productId, // ok
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent {
+        private final UUID productId; // ok
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent(UUID productId, String identifier) {
+            this.productId = productId;
+            this.identifier = identifier;
+        }
+    }
+
+    public record IdentifiersPair2(
+        HashSet x, // violation
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent2 {
+        private final HashSet x; // violation
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent2(Set x, String identifier) { // ok
+            this.x = (HashSet) x; // ok
+            this.identifier = identifier;
+        }
+    }
+
+}
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersPublicProtectedStatic.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersPublicProtectedStatic.java
new file mode 100644
--- /dev/null
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalTypeRecordsWithMemberModifiersPublicProtectedStatic.java
@@ -0,0 +1,63 @@
+/*
+IllegalType
+validateAbstractClassNames = (default)false
+illegalClassNames = (default)HashMap, HashSet, LinkedHashMap, LinkedHashSet, TreeMap, TreeSet, \
+                    java.util.HashMap, java.util.HashSet, java.util.LinkedHashMap, \
+                    java.util.LinkedHashSet, java.util.TreeMap, java.util.TreeSet
+legalAbstractClassNames = (default)
+ignoredMethodNames = (default)getEnvironment, getInitialContext
+illegalAbstractClassNameFormat = (default)^(.*[.])?Abstract.*$
+memberModifiers = LITERAL_PUBLIC, LITERAL_PROTECTED, LITERAL_STATIC
+tokens = (default)ANNOTATION_FIELD_DEF, CLASS_DEF, INTERFACE_DEF, METHOD_CALL, METHOD_DEF, \
+         METHOD_REF, PARAMETER_DEF, VARIABLE_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, \
+         RECORD_COMPONENT_DEF
+
+
+*/
+
+//non-compiled with javac: Compilable with Java14
+package com.puppycrawl.tools.checkstyle.checks.coding.illegaltype;
+
+import java.util.*;
+
+public class InputIllegalTypeRecordsWithMemberModifiersPublicProtectedStatic
+{
+
+    public record IdentifiersPair(
+        UUID productId, // ok
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent {
+        private final UUID productId; // ok
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent(UUID productId, String identifier) {
+            this.productId = productId;
+            this.identifier = identifier;
+        }
+    }
+
+    public record IdentifiersPair2(
+        HashSet x, // violation
+        String identifier // ok
+    )
+    {
+
+    }
+
+    public class IdentifiersPairEquivalent2 {
+        private final HashSet x; // ok
+        private final String identifier; // ok
+
+        public IdentifiersPairEquivalent2(Set x, String identifier) { // ok
+            this.x = (HashSet) x; // ok
+            this.identifier = identifier;
+        }
+    }
+
+}
+