You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Beam JIRA Bot (Jira)" <ji...@apache.org> on 2022/03/15 17:26:01 UTC

[jira] [Commented] (BEAM-13020) Fragile reference to private synthetic this$ field

    [ https://issues.apache.org/jira/browse/BEAM-13020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17507100#comment-17507100 ] 

Beam JIRA Bot commented on BEAM-13020:
--------------------------------------

This issue is P2 but has been unassigned without any comment for 60 days so it has been labeled "stale-P2". If this issue is still affecting you, we care! Please comment and remove the label. Otherwise, in 14 days the issue will be moved to P3.

Please see https://beam.apache.org/contribute/jira-priorities/ for a detailed explanation of what these priorities mean.


> Fragile reference to private synthetic this$ field
> --------------------------------------------------
>
>                 Key: BEAM-13020
>                 URL: https://issues.apache.org/jira/browse/BEAM-13020
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Liam Miller-Cushon
>            Priority: P2
>              Labels: stale-P2, starter
>
> The following code is using reflection to access a field with a name starting with `this$`:
> [https://github.com/apache/beam/blob/4fbdcca377fb9d804433f3014a7e7dfcef2e02f9/runners/spark/src/main/java/org/apache/beam/runners/spark/SparkNativePipelineVisitor.java#L186]
> 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.
> For example, given:
> {code:java}
> class Outer {
>   int x;
>   class Inner1 {
>     int f() {
>       return x;
>     }
>   }
>   class Inner2 {
>     void g() {
>       System.err.println("hello");
>     }
>   }
> }
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)