Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scala/scala
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 950992a
Choose a base ref
...
head repository: retronym/scala
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 53c7beb
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Aug 4, 2016

  1. Tweak module initialization to comply with JVM spec

    Dmitry learned that we've been relying on a bug in the
    verifier that will be fixed in JDK 9 under the new
    classfile format.
    
    Assignment to a static final must occur lexically
    within the <clinit>. We were performing this assignment
    from the constructor of the module class.
    
    This commit moves the assignment to <clinit>.
    
    Before:
    
    ```
    public final class O$ {
      public static final O$ MODULE$;
    
      public static {};
        Code:
           0: new           #2                  // class O$
           3: invokespecial #12                 // Method "<init>":()V
           6: return
    
      private O$();
        Code:
           0: aload_0
           1: invokespecial #13                 // Method java/lang/Object."<init>":()V
           4: aload_0
           5: putstatic     #15                 // Field MODULE$:LO$;
           8: return
    }
    ```
    
    After:
    
    ```
    public final class O$ {
      public static final O$ MODULE$;
    
      public static {};
        Code:
           0: new           #2                  // class O$
           3: dup
           4: invokespecial #12                 // Method "<init>":()V
           7: putstatic     #14                 // Field MODULE$:LO$;
          10: return
    
      private O$();
        Code:
           0: aload_0
           1: invokespecial #15                 // Method java/lang/Object."<init>":()V
           4: return
    }
    ```
    
    The difference is observable is the constructor is called a second
    time with reflection/setAccessible. That used to overwrite the
    `MODULE$` field. I think few would argue that the new semantics
    are a clear improvement.
    retronym committed Aug 4, 2016
    Configuration menu
    Copy the full SHA
    53c7beb View commit details
    Browse the repository at this point in the history
Loading