jtulach opened a new pull request, #4422: URL: https://github.com/apache/netbeans/pull/4422
I have a project that is using `record` heavily, but still compiles to old JDKs. When I run NetBeans on JDK-8 everything is OK, but when I run them on JDK-11 I get an error:  My project consists of a `pom.xml` file requesting `source` `18`: ```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.netbeans.test</groupId> <artifactId>userecords</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <dependencies> <dependency> <groupId>org.frgaal</groupId> <artifactId>compiler-maven-plugin</artifactId> <version>19.0.0-RC1</version> </dependency> </dependencies> <configuration> <compilerId>frgaal</compilerId> <source>18</source> <target>8</target> <compilerArgs> <arg>-Xlint:deprecation</arg> <arg>--enable-preview</arg> </compilerArgs> </configuration> </plugin> </plugins> </build> </project> ``` and a `Main.java` class using the `record`: package test; record Main(Object data) { public static void main(String... args) { Main m = new Main("Hello"); String reply = findReply(m); System.err.println(m.data() + ": " + reply); m = new Main(10); reply = findReply(m); System.err.println(m.data() + ": " + reply); } private static String findReply(Object o) { return switch (o) { case Main m -> " world"; case Object x -> " any"; }; } } ```java package test; record Main(Object data) { public static void main(String... args) { Main m = new Main("Hello"); String reply = findReply(m); System.err.println(m.data() + ": " + reply); m = new Main(10); reply = findReply(m); System.err.println(m.data() + ": " + reply); } private static String findReply(Object o) { return switch (o) { case Main m -> " world"; case Object x -> " any"; }; } } ``` turns out we just need to expand the check in `JavacParser` to verify that source level >= 15 also has access to `java.lang.Record` class. I'd like to get this fix into NetBeans 15 - I am using this project setup a lot and I always have to restart NetBeans on JDK8 to avoid the error. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
