Is it possible to use the Java feature "record class" in Processing?

I want to record class in Processing. (https://docs.oracle.com/en/java/javase/17/language/records.html#GUID-6699E26F-4A9B-4393-A08B-1E47D4B2D263)
for example

record Foo(double length, double width) { }

But Processing say Class “record” does not exist. Cannot I use the java feature? If I can use it, what should I do? If I cannot use it, why?

Processing’s “syntax” is determined by its pre-processor, which concatenates & transpiles everything inside “.pde” files into “.java” files.

As a workaround, you may try out your luck by moving your record blocks to separate “.java” tabs, where the PDE’s pre-processor won’t touch.

1 Like

Thank you. I knew I imagined that would be the case.

And as for the new question, what I want to know is to what extent does the Processing preprocessor allow Java functionality? I was wondering about this.

So, after a bit of source code research, I found what looks like a Java parser for Processing, and it seems that if I fork these and modify them, I can create a Processing that can use Java 17 features, so I would like to try that one.

1 Like

Hi @nobkz,

If you want to update that for your fork, you can look here at the java17 JaveLexer.g4 and JavaParser.g4 for the definition. But still you have to integrate it …

Cheers
— mnse

1 Like