Skip to content

'Type Pattern' being reported as an error even though Java source level is above 16 #3721

Closed
microsoft/build-server-for-gradle
#188
@JojoFR1

Description

@JojoFR1

While modding for the game Mindustry, I noticed that I get the error The Java feature 'Type Patterns' is only available with source level 16 and above - Java(4195411) while doing 'Type Pattern' even though the sourceLevel is set to 17 (see linked mod template repository down below).
The explanation for this error might be because targetLevel is set to 8 and the --release 8 argument is also added. If you are wondering why it is like that... I do not know but one of the dependecy, jabel (https://github.com/Anuken/jabel), is supposed to make the Java 17 features be retro compatible with Java 8.

Environment
  • Operating System: Windows 11
  • JDK version: OpenJDK Runtime Environment Temurin-22.0.1+8 (build 22.0.1+8)
  • Visual Studio Code version: 1.91.1
  • Java extension version: 1.33.2024072008
Steps To Reproduce
  1. Clone https://github.com/Anuken/MindustryJavaModTemplate
  2. Add (anywhere) some simple Type Pattern cast (e.g. below)
Object test = 2f;
if (test instanceof Float f) {

}
  1. Try to build using gradle jar or ./grawled jar, it should be succesful.
Current Result

The 'Type Pattern' are being reported as an error, even though it builds fine (and run fine in-game too, but I don't expect you to bother trying.)

Expected Result

The 'Type Pattern' to not be reported as an error, or at least be able to ignore the error.

Additional Informations

Due to the specific situation, it might not be possible to fix this, so maybe adding the option to ignore error is a possible way if it's possible for you to do.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions