Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to execute mvn clean verify in the JDK 17 showing invalid use of a restricted identifier 'yield' #13840

Closed
AayushSaini101 opened this issue Oct 6, 2023 · 10 comments

Comments

@AayushSaini101
Copy link
Contributor

AayushSaini101 commented Oct 6, 2023

Using the env JDK 17, Cannot able to run the mvn clean verify. Showing below error:

Log:
image

[ERROR] /Users/aaayush/Desktop/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/antlr4/InputAntlr4AstRegressionTrickyYield.java:[8,16] invalid use of a restricted identifier 'yield'
[ERROR]   (to invoke a method called yield, qualify the yield with a receiver or type name)

Java Version Used:


java -version 
java version "17.0.7" 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

Pom Configuration:

<configuration>
          <source>17</source>
          <target>17</target>
          <compilerArgs>
            <arg>-Xpkginfo:always</arg>
          </compilerArgs>
  </configuration>

@romani
Copy link
Member

romani commented Oct 7, 2023

@AayushSaini101
Copy link
Contributor Author

AayushSaini101 commented Oct 7, 2023

I thought we do this jdk usage in some CI.

https://dev.azure.com/romanivanovjr/romanivanovjr/_build/results?buildId=16894&view=logs&j=d72e04f6-d294-5bfe-b3cd-ffcb523f40f9

This 90th line warning is causing an issue

[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ checkstyle ---
[INFO] Changes detected - recompiling the module! :dependency
[INFO] Compiling 3519 source files with javac [debug target 11] to target/test-classes
[WARNING] system modules path not set in conjunction with -source 11
[WARNING] /Users/runner/work/1/s/src/test/resources/com/puppycrawl/tools/checkstyle/
grammar/antlr4/
InputAntlr4AstRegressionTrickyYield.java:[8,16] 
'yield' may become a restricted identifier in a future release
  (to invoke a method called yield, qualify the yield 
with a receiver or type name)

@AayushSaini101
Copy link
Contributor Author

AayushSaini101 commented Oct 7, 2023

And blocking this #13086 (comment) we need to rename the yield name to some other name, this will fix the issue

@nrmancuso
Copy link
Member

➜  checkstyle git:(master) java --version
java 17.0.7 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

➜  checkstyle git:(master) git log -1 --oneline | cat
1e6aa29a3 Issue #13834: Add .vscodefoler in .gitignore

➜  checkstyle git:(master) mvn clean verify
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] 
[INFO] ------------------< com.puppycrawl.tools:checkstyle >-------------------
[INFO] Building checkstyle 10.12.5-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
...
[WARNING] /home/nick/IdeaProjects/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/antlr4/InputAntlr4AstRegressionTrickyYield.java:[8,16] 'yield' may become a restricted identifier in a future release
  (to invoke a method called yield, qualify the yield with a receiver or type name)
...

[INFO] Successfully validated JSON from /home/nick/IdeaProjects/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/ExpectedSarifLoggerSingleWarning.sarif against /home/nick/IdeaProjects/checkstyle/target/plexus-resources1043365814tmp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:08 min
[INFO] Finished at: 2023-10-06T23:51:50-04:00
[INFO] ------------------------------------------------------------------------

➜  checkstyle git:(master) uname -a
Linux fedora 6.4.14-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Sep  2 16:36:06 UTC 2023 x86_64 GNU/Linux

Build is passing for me on Fedora with the same jdk version.

@AayushSaini101 are you changing the pom? There is no need to make any changes to the pom in the scope of #13086

@AayushSaini101
Copy link
Contributor Author

AayushSaini101 commented Oct 7, 2023

➜  checkstyle git:(master) java --version
java 17.0.7 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

➜  checkstyle git:(master) git log -1 --oneline | cat
1e6aa29a3 Issue #13834: Add .vscodefoler in .gitignore

➜  checkstyle git:(master) mvn clean verify
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO]   ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO] 
[INFO] ------------------< com.puppycrawl.tools:checkstyle >-------------------
[INFO] Building checkstyle 10.12.5-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
...
[WARNING] /home/nick/IdeaProjects/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/grammar/antlr4/InputAntlr4AstRegressionTrickyYield.java:[8,16] 'yield' may become a restricted identifier in a future release
  (to invoke a method called yield, qualify the yield with a receiver or type name)
...

[INFO] Successfully validated JSON from /home/nick/IdeaProjects/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/sariflogger/ExpectedSarifLoggerSingleWarning.sarif against /home/nick/IdeaProjects/checkstyle/target/plexus-resources1043365814tmp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:08 min
[INFO] Finished at: 2023-10-06T23:51:50-04:00
[INFO] ------------------------------------------------------------------------

➜  checkstyle git:(master) uname -a
Linux fedora 6.4.14-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Sep  2 16:36:06 UTC 2023 x86_64 GNU/Linux

Build is passing for me on Fedora with the same jdk version.

@AayushSaini101 are you changing the pom? There is no need to make any changes to the pom in the scope of #13086

Reference of this issue: #13086 When I add a new test case of the enhanced switch for validation, IDE automatically shows me to switch JDK 14+. Currently, I am using default pom, After this, it is showing the above error that I have mentioned while running the test. Platform: Mac OS
Screenshot 2023-10-07 at 9 34 29 AM

@nrmancuso
Copy link
Member

You need to add test cases for jdk 11+ to noncompilable directory.

@AayushSaini101
Copy link
Contributor Author

AayushSaini101 commented Oct 7, 2023

You need to add test cases for jdk 11+ to noncompilable directory.

Can you please highlight how can i add to the suitable directory? or share the location where I need to add

@nrmancuso
Copy link
Member

➜  checkstyle git:(master) find . -type d -name '*noncompilable'
./src/it/resources-noncompilable
./src/test/resources-noncompilable
./src/xdocs-examples/resources-noncompilable

Each test resources directory has a matching noncompilable directory for inputs that use a higher jdk version than Checkstyle supports. You want to put your new inputs into the ./src/test/resources-noncompilable directory, as was done in https://github.com/checkstyle/checkstyle/pull/13090/files

@nrmancuso
Copy link
Member

@AayushSaini101 let's close this issue if you cannot reproduce this in the master branch.

@AayushSaini101
Copy link
Contributor Author

@AayushSaini101 let's close this issue if you cannot reproduce this in the master branch.

Okay Closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants