You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The OpenJDK javac generates private synthetic fields with names starting with this$ as an implementation detail of inner classes. In the future that implementation detail may be changing, and the this$ field will no longer be generated for all inner classes. For more information about the proposed change, see: https://bugs.openjdk.java.net/browse/JDK-8271717
Please consider alternatives to accessing the private synthetic this$ field to ensure this code continues to work after the change. For example, consider passing an explicit copy of the enclosing instance to code that needs access to it, or adding an explicit getter to the inner class.
Currently Inner1 and Inner2 both have a synthetic field named this$0 that stores a reference to Outer.
In the future the implementation detail might be changing to omit the field from classes that don't reference the enclosing instance. So in the example, Inner1 would still have the synthetic field because it accesses the field x in the enclosing instance Outer. However Inner2 would no longer have a synthetic field, because it doesn't access any state from its enclosing instance.
The text was updated successfully, but these errors were encountered:
The following code is using reflection to access a field with a name starting with
this$
:micrometer/micrometer-test/src/main/java/io/micrometer/core/tck/RegistryResolver.java
Line 51 in 55892ea
The OpenJDK javac generates private synthetic fields with names starting with
this$
as an implementation detail of inner classes. In the future that implementation detail may be changing, and thethis$
field will no longer be generated for all inner classes. For more information about the proposed change, see: https://bugs.openjdk.java.net/browse/JDK-8271717Please consider alternatives to accessing the private synthetic
this$
field to ensure this code continues to work after the change. For example, consider passing an explicit copy of the enclosing instance to code that needs access to it, or adding an explicit getter to the inner class.For example, given:
Currently
Inner1
andInner2
both have a synthetic field namedthis$0
that stores a reference toOuter
.In the future the implementation detail might be changing to omit the field from classes that don't reference the enclosing instance. So in the example,
Inner1
would still have the synthetic field because it accesses the fieldx
in the enclosing instanceOuter
. HoweverInner2
would no longer have a synthetic field, because it doesn't access any state from its enclosing instance.The text was updated successfully, but these errors were encountered: