Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHH-13682 Generate Java 11/13/14 bytecode for tests when building with JDK11/13/14 #3329

Merged
merged 6 commits into from
Apr 14, 2020

Commits on Apr 7, 2020

  1. HHH-13682 Remove unnecessary checks around Java 8 compatibility

    The build requires JDK8+, so we're alwways Java 8 compatible.
    yrodiere committed Apr 7, 2020
    Configuration menu
    Copy the full SHA
    0cd7d03 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c11cdc6 View commit details
    Browse the repository at this point in the history
  3. HHH-13682 Do not set net.bytebuddy.experimental=true in tests anymore

    It's no longer necessary since we upgraded to byte-buddy 1.10.2,
    and it causes bytecode to be converted from Java 14 to Java 12 in some
    cases (I don't know why).
    yrodiere committed Apr 7, 2020
    Configuration menu
    Copy the full SHA
    e6685a1 View commit details
    Browse the repository at this point in the history
  4. HHH-13682 Enable extended bytecode enhancement in NaturalIdInUninitia…

    …lizedAssociationTest
    
    This test accesses a field of an entity directly and expects it to be
    automatically initialized; this cannot work without extended bytecode
    enhancement.
    
    This used to work with Java 8 bytecode, but only by chance. It seems
    that Java 8 bytecode relies on "synthetic", static access methods
    inserted by the compiler to access the fields of entities in this test:
    any access to the field is done through this access method instead of
    through a direct field access. Since we apply bytecode enhancement to
    all methods of entities, this means that access to fields triggers
    initialization, without any bytecode enhancement in the caller class.
    
    I believe this is specific to nested classes, but couldn't find a
    source. For reference, the bytecode of access methods looks like this:
    
      static int access$002(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, int);
        Code:
           0: aload_0
           1: iload_1
           2: dup_x1
           3: putfield      hibernate#3                  // Field id:I
           6: ireturn
    
      static org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId access$102(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId);
        Code:
           0: aload_0
           1: aload_1
           2: dup_x1
           3: putfield      hibernate#2                  // Field entityImmutableNaturalId:Lorg/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId;
           6: areturn
    
    With Java 11, however, access to fields of entities is done directly,
    even for nested classes. So the access methods no longer exist, and we
    don't get automatic initialization upon field access. We need extended
    bytecode enhancement, like we would in any other case of field access
    (in particular accessing fields of non-nested classes).
    yrodiere committed Apr 7, 2020
    Configuration menu
    Copy the full SHA
    b971581 View commit details
    Browse the repository at this point in the history
  5. HHH-13682 Allow forcing the tested Java version in the Gradle build

    ... just in case we need that for some cutting-edge JDK, for example 15,
    that would not be supported by Gradle yet.
    yrodiere committed Apr 7, 2020
    Configuration menu
    Copy the full SHA
    73ba5d9 View commit details
    Browse the repository at this point in the history
  6. HHH-13682 Upgrade to forbiddenapis 2.7

    So that we can feed it Java 13/14 bytecode
    yrodiere committed Apr 7, 2020
    Configuration menu
    Copy the full SHA
    fc9ff84 View commit details
    Browse the repository at this point in the history