Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Restricted Identifier Error in Eclipse when using Mockitos when(Eclipse Error Java 21 with Mockitos 'when' method)
Restricted Identifier Error in Eclipse when using Mockitos when [message #1861681] Fri, 27 October 2023 03:49 Go to next message
Eclipse UserFriend

Eclipse shows an Error (Syntax error on token "RestrictedIdentifierWhen", delete this token) when using the Mockito when method which is a static import.

Often the error is just shown for the first occurence of a 'when' in a test Method.

If i see it correctly 'when' is only restricted for identifiers in a 'switch case' statement.

Workarround is to use the fully qualified name org.mockito.Mockito.when.

I use the following version:

Eclipse JDT (Java Development Tools) Patch with Java 21 support for 2023-09 development stream 1.2.300.v20230920-0334_BETA_JAVA21 org.eclipse.jdt.java21patch.feature.group Eclipse.org
Re: Restricted Identifier Error in Eclipse when using Mockitos when [message #1861686 is a reply to message #1861681] Fri, 27 October 2023 10:56 Go to previous messageGo to next message
Eclipse UserFriend
If you think there is a problem, best to report it here:

https://github.com/eclipse-jdt/eclipse.jdt.core

Please provide sufficient detail (i.e., test case) for someone else to reproduce the problem.

You might want to check that https://www.eclipse.org/downloads/packages/release/2023-12/m2 hasn't already fixed the problem...
Re: Restricted Identifier Error in Eclipse when using Mockitos when [message #1861704 is a reply to message #1861686] Mon, 30 October 2023 04:40 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the info. I followed your advice and filed an issue:
https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1536
Re: Restricted Identifier Error in Eclipse when using Mockitos when [message #1861741 is a reply to message #1861704] Wed, 01 November 2023 03:35 Go to previous message
Eclipse UserFriend
Just to inform here:
It is fixed in the actual 2023-12 m2 Version.
Previous Topic:Eclipse Gradle JUnit Test Issue?
Next Topic:Java 21 guarded patterns in switch
Goto Forum:
  


Current Time: Tue Jul 08 02:08:58 EDT 2025

Powered by FUDForum. Page generated in 0.06174 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top