[hibernate-commits] [hibernate/hibernate-orm] c90698: HHH-13682 Remove unnecessary checks around Java 8 ...

Yoann Rodière noreply at github.com
Tue Apr 14 08:37:00 EDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/hibernate/hibernate-orm
  Commit: c906989989ca35e87fad19e0b4154e3cf936428f
      https://github.com/hibernate/hibernate-orm/commit/c906989989ca35e87fad19e0b4154e3cf936428f
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

  Changed paths:
    M documentation/documentation.gradle
    M gradle/published-java-module.gradle

  Log Message:
  -----------
  HHH-13682 Remove unnecessary checks around Java 8 compatibility

The build requires JDK8+, so we're alwways Java 8 compatible.


  Commit: 0cdf4c19e3d2f64b0538639211a1295904930b6e
      https://github.com/hibernate/hibernate-orm/commit/0cdf4c19e3d2f64b0538639211a1295904930b6e
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

  Changed paths:
    M gradle/base-information.gradle
    M gradle/java-module.gradle
    M hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle

  Log Message:
  -----------
  HHH-13682 Generate Java 13/14 bytecode for tests when building with JDK13/14


  Commit: 96f7870528cfcfeaf28f090b059f069ad253a485
      https://github.com/hibernate/hibernate-orm/commit/96f7870528cfcfeaf28f090b059f069ad253a485
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

  Changed paths:
    M gradle/java-module.gradle

  Log Message:
  -----------
  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).


  Commit: 1060baf74b3d480d026a3d88e9c4b2d4aae118a3
      https://github.com/hibernate/hibernate-orm/commit/1060baf74b3d480d026a3d88e9c4b2d4aae118a3
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

  Changed paths:
    M hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest.java

  Log Message:
  -----------
  HHH-13682 Enable extended bytecode enhancement in NaturalIdInUninitializedAssociationTest

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      #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      #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).


  Commit: b32ff5cd9c8da14fc2b756ccca2fdc860403b113
      https://github.com/hibernate/hibernate-orm/commit/b32ff5cd9c8da14fc2b756ccca2fdc860403b113
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

  Changed paths:
    M build.gradle
    M gradle/base-information.gradle
    M gradle/java-module.gradle
    M hibernate-integrationtest-java-modules/hibernate-integrationtest-java-modules.gradle
    M settings.gradle

  Log Message:
  -----------
  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.


  Commit: 5fab58bf767951ff1bebc74c06866237cb01c347
      https://github.com/hibernate/hibernate-orm/commit/5fab58bf767951ff1bebc74c06866237cb01c347
  Author: Yoann Rodière <yoann at hibernate.org>
  Date:   2020-04-14 (Tue, 14 Apr 2020)

  Changed paths:
    M gradle/java-module.gradle

  Log Message:
  -----------
  HHH-13682 Upgrade to forbiddenapis 2.7

So that we can feed it Java 13/14 bytecode


Compare: https://github.com/hibernate/hibernate-orm/compare/0069aa7be943...5fab58bf7679



More information about the hibernate-commits mailing list