RFR: 8242451: ensure semantics of non-capturing lambdas are preserved independent of execution mode [v4]

Gilles Duboscq gdub at openjdk.java.net
Tue Sep 22 18:03:37 UTC 2020


> [JDK-8232806](https://bugs.openjdk.java.net/browse/JDK-8232806) introduced the
> jdk.internal.lambda.disableEagerInitialization system property to be able to disable eager initialization of lambda
> classes. This was necessary to prevent side effects of class initializers triggered by such initialization in the
> context of the GraalVM native image tool.  However, the change as it is implemented means that the behaviour of
> non-capturing lambdas depends on the value of `disableEagerInitialization`: when it is false (the default) such lambdas
> are actually a singleton while when it is true, a fresh instance is returned every time.  Programs should definitely
> _not_ rely on reference equality since the Java spec does not guarantee it. However, in order to separate concern and
> ease debugging such bad programs, `disableEagerInitialization` shouldn't influence the singleton vs. fresh instance
> behaviour of lambdas in either direction.

Gilles Duboscq has refreshed the contents of this pull request, and previous commits have been removed. The incremental
views will show differences compared to the previous content of the PR. The pull request contains six new commits since
the last revision:

 - Move LambdaEagerInitTest to test/jdk/java/lang/invoke/lambda
 - Include capturing case test, use  jdk.test.lib.Assert
 - Remove disableEagerInitialization concerns from BridgeMethod.java
 - Remove extra field test from LambdaTest6
 - Wrap long lines
 - Add dedicated test in the jdk tests

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/93/files
  - new: https://git.openjdk.java.net/jdk/pull/93/files/625feb94..5525f217

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=93&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=93&range=02-03

  Stats: 164 lines in 2 files changed: 91 ins; 73 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/93.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/93/head:pull/93

PR: https://git.openjdk.java.net/jdk/pull/93


More information about the compiler-dev mailing list