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

**URL:** <https://discourse.processing.org/t/is-it-possible-to-use-the-java-feature-record-class-in-processing/42591>\
**Category:** Beginners\
**Created:** [August 14, 2023, 5:20am UTC](https://discourse.processing.org/t/is-it-possible-to-use-the-java-feature-record-class-in-processing/42591 "2023-08-14T05:20:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobkz](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@nobkz](https://discourse.processing.org/u/nobkz)\
**Post date:** [August 14, 2023, 5:20am UTC](https://discourse.processing.org/t/is-it-possible-to-use-the-java-feature-record-class-in-processing/42591/1 "2023-08-14T05:20:19Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 14, 2023, 8:00am UTC](https://discourse.processing.org/t/is-it-possible-to-use-the-java-feature-record-class-in-processing/42591/2 "2023-08-14T08:00:42Z")

</div>

> [@nobkz](#):
>
> 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.

> [@nobkz](#):
>
> If I can use it, what should I do?

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.

---

<div class="post-metadata">

**Author:** ![nobkz](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@nobkz](https://discourse.processing.org/u/nobkz)\
**Post date:** [August 15, 2023, 2:26am UTC](https://discourse.processing.org/t/is-it-possible-to-use-the-java-feature-record-class-in-processing/42591/3 "2023-08-15T02:26:28Z")

</div>

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.

> <https://github.com/processing/processing4/blob/main/java/src/processing/mode/java/preproc/JavaParser.g4>

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [August 15, 2023, 4:27am UTC](https://discourse.processing.org/t/is-it-possible-to-use-the-java-feature-record-class-in-processing/42591/4 "2023-08-15T04:27:20Z")

</div>

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 …

> <https://github.com/antlr/grammars-v4/tree/master/java/java/>
>
> //github.com/antlr/grammars-v4/tree/master/java/java/

Cheers  
— mnse
