-
How can synthetic fields be created in Java?
-
Can synthetic fields in java only be created at runtime?
If not: Is there a standard-compliant way to this at compile time (without changing some bytes in the class file)
How can synthetic fields be created in Java? Can synthetic fields in java only
Share
They’re created by the compiler when “oddities” of the language require them. A simple example of this is using an inner class:
The
Test.Innerclass will have a synthetic field to represent the appropriate instance of theTestclass.We can extend this code slightly to show that field:
With my compiler, that prints: