They are associated with a class, but the class is basically the file. There are limitations by doing it this way but it is out of preview and officially supported as of Java 25.
https://openjdk.org/jeps/512