-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Build Android flavor with -source 8 -target 8
(but still avoid Java 7+ APIs)
#5269
Comments
Migrating from Java 7 to Java 8 is recommended because of New language features, security improvements, Optimum performance, Writing code more efficiently, Oracle recommendation to uninstall pre-8 versions to avoid security risks, Older releases no longer publicly supported, Third party Java libraries no longer being developed and supported. To check the new features in JDK 8 by library - check https://www.oracle.com/java/technologies/javase/8-whats-new.html To check incompatibilities between JDK 7 and JDK 8 - https://www.oracle.com/java/technologies/javase/8-compatibility-guide.html#A999387 To check incompatibilities between Java SE 7 and SE 8 - https://www.oracle.com/java/technologies/javase/8-compatibility-guide.html#A999198 To check Features removed in JDK 8 - https://www.oracle.com/java/technologies/javase/8-compatibility-guide.html#A999476 To check Features removed in Java SE 8 - https://www.oracle.com/java/technologies/javase/8-compatibility-guide.html#CHDGHIIH I do not anticipate any change in Applications using Guava as long as the API's remain the same and return the same result as they used to when they were in Java 7. Hope this helps resolve the issue. |
More precisely, log a warning if lambda expressions or type annotations in our classes would produce an exception. If someone wants to use Retrolambda or a similar tool to rewrite our classes, that's fine with us if it works. And our support for Android is unchanged: The Android toolchain rewrites lambdas and removes type annotations. This is a step toward removing Java 7 support entirely: #5269 RELNOTES=Introduced a warning log message when running under Java 7. This warning is not _guaranteed_ to be logged when running under Java 7, so please don't rely on it as your only warning about future problems. If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.MoreObjects$ToStringHelper` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](#5269). Please report any problems. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=346795766
More precisely, log a warning if lambda expressions or type annotations in our classes would produce an exception. If someone wants to use Retrolambda or a similar tool to rewrite our classes, that's fine with us if it works. And our support for Android is unchanged: The Android toolchain rewrites lambdas and removes type annotations. This is a step toward removing Java 7 support entirely: #5269 RELNOTES=Introduced a warning log message when running under Java 7. This warning is not _guaranteed_ to be logged when running under Java 7, so please don't rely on it as your only warning about future problems. If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.MoreObjects$ToStringHelper` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](#5269). Please report any problems. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=346795766
Out or curiosity, what's the downside of requiring library desugaring? |
For most users, it's probably a reasonable thing to enable. However, there are downsides in some cases. As I understand them, the downsides are:
|
RELNOTES=Increased the aggressiveness of [Guava 30.1](https://github.com/google/guava/releases/tag/v30.1)'s warning log message for running `guava-android` under a Java 7 VM. (Android VMs are unaffected.) If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.Preconditions` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](#5269). Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, especially as aggressively as we do in this new release, there is the potential for [`NullPointerException`](https://stackoverflow.com/a/41017717/28465) or even [deadlock](https://stackoverflow.com/a/48009613/28465). (To be clear, Guava will not log under Java 8 or Android, but it will under Java 7.) PiperOrigin-RevId: 361604103
RELNOTES=Increased the aggressiveness of [Guava 30.1](https://github.com/google/guava/releases/tag/v30.1)'s warning log message for running `guava-android` under a Java 7 VM. (Android VMs are unaffected.) If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.Preconditions` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](#5269). Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, especially as aggressively as we do in this new release, there is the potential for [`NullPointerException`](https://stackoverflow.com/a/41017717/28465) or even [deadlock](https://stackoverflow.com/a/48009613/28465). (To be clear, Guava will not log under Java 8 or Android, but it will under Java 7.) PiperOrigin-RevId: 361700569
Relevant to #5269 in that it's an exception -- a case in which we *are* willing to use a Java 7 API because we know this particular API is safe to use under Android. RELNOTES=n/a PiperOrigin-RevId: 364549818
Relevant to #5269 in that it's an exception -- a case in which we *are* willing to use a Java 7 API because we know this particular API is safe to use under Android. RELNOTES=n/a PiperOrigin-RevId: 364567470
…sage. This is largely a rollback of the original Java8Usage change, but I've modified it in a few ways: - I set `-source 8 -target 8` in the backport. - I kept the code to make includes/excludes fully work with maven-compiler-plugin, since that could save us some confusion down the line. - I incorporated a rollback of the changes to Preconditions from CL 361700569, in which I moved the warning from MoreObjects to Preconditions. - I added errors to our internal release scripts so that we don't accidentally make a release that drops Java 7 support before we're ready. Fixes #5269 PiperOrigin-RevId: 364405695
We started seeing this in Firebase Java SDK builds:
We would certainly like to drop Java 7 support, but not before the larger Google Cloud client libraries ecosystem decides to do so. AFAICT cloud libraries like Firestore and Storage are still Java 7 compatible. Has a decision been made to migrate all these libraries to Java 8? |
Hi, thanks for reporting that. We have been in contact with the Google Cloud people, and we won't be dropping support unless they are. Part of the reason for this warning was to share any information we could find with them. |
…e to 30.1.1-jre Updated to addres an identified issue - `io`: Deprecated `Files.createTempDir()`. ([fec0dbc](google/guava@fec0dbc)) ([CVE-2020-8908](https://nvd.nist.gov/vuln/detail/CVE-2020-8908); continuing discussion in [#4011](google/guava#4011)) - Increased the aggressiveness of [Guava 30.1](https://github.com/google/guava/releases/tag/v30.1)'s warning log message for running `guava-android` under a Java 7 VM. (Android VMs are unaffected.) If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.Preconditions` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](google/guava#5269). Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, especially as aggressively as we do in this new release, there is the potential for [`NullPointerException`](https://stackoverflow.com/a/41017717/28465) or even [deadlock](https://stackoverflow.com/a/48009613/28465). (To be clear, Guava will not log under Java 8 or Android, but it will under Java 7.) ([00c25e9](google/guava@00c25e9)) - `cache`: Fixed compatibility between `asMap().compute(...)` and a load. ([42bf4f4](google/guava@42bf4f4)) - `cache`: Added `@CheckReturnValue` to some APIs. ([a5ef129](google/guava@a5ef129)) - `collect`: Added `@DoNotCall` to the mutator methods on immutable types ([6ae9532](google/guava@6ae9532)) - `hash`: Removed `@Beta` from `HashCode`. ([2c9f161](google/guava@2c9f161)) - `io`: Removed `@Beta` from `CountingOutputStream`. ([d394bac](google/guava@d394bac847467039530f514f880ecca27263d0ff))i - If you use guava-android in an Android project (as opposed to from a Java VM), you will need to [enable desugaring of Java 8 _language features_](https://developer.android.com/studio/write/java8-support.html#supported_features) if you have not already done so. (And if you are releasing an Android _library_, then anyone who uses that library will also have to enable desugaring.) We expect for nearly all Android projects to have already enabled desugaring. But if this causes problems for you, please let us know on [issue #5358](google/guava#5358). The purpose of this change is to detect potential problems for users now so that we can plan to use Java 8 language features in our implementation later this year. - Introduced a warning log message when running `guava-android` under a Java 7 VM. (Android VMs are unaffected, aside from the need to use desugaring, described in the previous bullet.) This warning is not _guaranteed_ to be logged when running under Java 7, so please don't rely on it as your only warning about future problems. If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.MoreObjects$ToStringHelper` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](google/guava#5269). Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, there is the potential for [`NullPointerException`](https://stackoverflow.com/a/41017717/28465) or even [deadlock](https://stackoverflow.com/a/48009613/28465). (To be clear, Guava will _not_ log under Java 8 or Android, but it _may_ log under Java 7.) ([dc52e6e](google/guava@dc52e6e)) - Note that we subsequently made this warning more aggressive in [Guava 30.1.1](https://github.com/google/guava/releases/tag/v30.1.1), including changing the logger it uses to `com.google.common.base.Preconditions`. - `base`: Deprecated `StandardSystemProperty.JAVA_EXT_DIRS`. We do not plan to remove the API, but note that, under recent versions of Java, that property always has a value of `null`. ([38abf07](google/guava@38abf07)) - `net`: Added `HttpHeaders` constants for `Origin-Isolation` and `X-Request-ID`. ([a48fb4f](google/guava@a48fb4f), [8319d20](google/guava@8319d20)) - `reflect`: Added `ClassInfo.isTopLevel()`. ([4106272](google/guava@4106272)) - `util.concurrent`: Added `ClosingFuture.submitAsync(AsyncClosingCallable)`. ([c5e2d8d](google/guava@c5e2d8d)) - [Guava types can no longer be sent over GWT-RPC.](https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ) Even the earlier, temporary way to reenable support (`guava.gwt.emergency_reenable_rpc`) no longer has an effect. ([0cb89dd](google/guava@0cb89dd)) - `cache`: Fixed memory leak in `LocalCache` under [j2objc](https://developers.google.com/j2objc). ([5e519d9](google/guava@5e519d9)) - `collect`: Added two-element `min` and `max` methods to `Comparators`. ([958186c](google/guava@958186c)) - `collect`: Removed `@Beta` from `Multimaps.toMultimap`. ([b6b4dc4](google/guava@b6b4dc4)) - `collect`: Made the set returned by `ImmutableMap<K, V>.keySet()` serializable as long as `K` is serializable, even if `V` is not (and similarly for `values()`). ([f5a69c3](google/guava@f5a69c3)) - `collect`: Fixed bug in `powerSet.equals(otherPowerSet)` would erroneously return `false` if the two power sets' underlying sets were equal but had a different iteration order. ([215b1f0](google/guava@215b1f0)) - `collect`: Eliminated [j2objc](https://developers.google.com/j2objc) retain-cycle in `SingletonImmutableBiMap`. ([0ad38b8](google/guava@0ad38b8)) - `eventbus`: Prevented `@Subscribe` from being applied to a method that takes a primitive, as that will never be called. ([554546c](google/guava@554546c)) - `graph`: Made `Traverser.breadthFirst()` lazier, and optimized `Traverser` more generally. ([32f2d77](google/guava@32f2d77), [b5210ca](google/guava@b5210ca)) - `graph`: Added `@DoNotMock` to `Traverser`. ([6410f18](google/guava@6410f18)) - `io`: Deprecated `Files.createTempDir()`. ([fec0dbc](google/guava@fec0dbc)) ([CVE-2020-8908](https://nvd.nist.gov/vuln/detail/CVE-2020-8908); continuing discussion in [#4011](google/guava#4011)) - `io`: Upgraded `ByteStreams.copy(InputStream, OutputStream)` to use the faster `FileChannel` if possible. ([a1e9a0b](google/guava@a1e9a0b)) [update: My mistake: This was [rolled back](google/guava@e839f94), so it did not make 30.0.] - `math`: Added `roundToDouble` to `BigDecimalMath`, `BigIntegerMath`, and `LongMath`. ([bee4f3c](google/guava@bee4f3c), [2b5c096](google/guava@2b5c096), [633abf2](google/guava@633abf2)) - `net`: Added `MediaType` constants for several font/ types. ([571cf66](google/guava@571cf66)) - `net`: Added `HttpHeaders` constants for `Cross-Origin-Embedder-Policy(-Report-Only)?`. ([c3bf731](google/guava@c3bf731)) - `testing`: Made `EqualsTester` test that non-`String` objects are not equal to their `String` representations. ([c9570ea](google/guava@c9570ea)) - `util.concurrent`: Added `ClosingFuture`. ([52e048e](google/guava@52e048e)) - `util.concurrent`: Removed the deprecated 1-arg `ServiceManager.addListener(Listener)`. Use the 2-arg `addListener(Listener, Executor)` overload, setting the executor to `directExecutor()` for equivalent behavior. ([dfb0001](google/guava@dfb0001)) - `util.concurrent`: Changed `AbstractFuture.toString()` to no longer include the `toString()` of the result. ([2ebf27f](google/guava@2ebf27f)) - `util.concurrent`: Added `awaitTerminationUninterruptibly`. ([f07b954](google/guava@f07b954))
…e to 30.1.1-jre (#28) Updated to addres an identified issue - `io`: Deprecated `Files.createTempDir()`. ([fec0dbc](google/guava@fec0dbc)) ([CVE-2020-8908](https://nvd.nist.gov/vuln/detail/CVE-2020-8908); continuing discussion in [#4011](google/guava#4011)) - Increased the aggressiveness of [Guava 30.1](https://github.com/google/guava/releases/tag/v30.1)'s warning log message for running `guava-android` under a Java 7 VM. (Android VMs are unaffected.) If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.Preconditions` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](google/guava#5269). Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, especially as aggressively as we do in this new release, there is the potential for [`NullPointerException`](https://stackoverflow.com/a/41017717/28465) or even [deadlock](https://stackoverflow.com/a/48009613/28465). (To be clear, Guava will not log under Java 8 or Android, but it will under Java 7.) ([00c25e9](google/guava@00c25e9)) - `cache`: Fixed compatibility between `asMap().compute(...)` and a load. ([42bf4f4](google/guava@42bf4f4)) - `cache`: Added `@CheckReturnValue` to some APIs. ([a5ef129](google/guava@a5ef129)) - `collect`: Added `@DoNotCall` to the mutator methods on immutable types ([6ae9532](google/guava@6ae9532)) - `hash`: Removed `@Beta` from `HashCode`. ([2c9f161](google/guava@2c9f161)) - `io`: Removed `@Beta` from `CountingOutputStream`. ([d394bac](google/guava@d394bac847467039530f514f880ecca27263d0ff))i - If you use guava-android in an Android project (as opposed to from a Java VM), you will need to [enable desugaring of Java 8 _language features_](https://developer.android.com/studio/write/java8-support.html#supported_features) if you have not already done so. (And if you are releasing an Android _library_, then anyone who uses that library will also have to enable desugaring.) We expect for nearly all Android projects to have already enabled desugaring. But if this causes problems for you, please let us know on [issue #5358](google/guava#5358). The purpose of this change is to detect potential problems for users now so that we can plan to use Java 8 language features in our implementation later this year. - Introduced a warning log message when running `guava-android` under a Java 7 VM. (Android VMs are unaffected, aside from the need to use desugaring, described in the previous bullet.) This warning is not _guaranteed_ to be logged when running under Java 7, so please don't rely on it as your only warning about future problems. If the warning _itself_ causes you trouble, you can eliminate it by silencing the logger for `com.google.common.base.MoreObjects$ToStringHelper` (which is used _only_ for this warning). This warning prepares for [removing support for Java 7 in 2021](google/guava#5269). Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, there is the potential for [`NullPointerException`](https://stackoverflow.com/a/41017717/28465) or even [deadlock](https://stackoverflow.com/a/48009613/28465). (To be clear, Guava will _not_ log under Java 8 or Android, but it _may_ log under Java 7.) ([dc52e6e](google/guava@dc52e6e)) - Note that we subsequently made this warning more aggressive in [Guava 30.1.1](https://github.com/google/guava/releases/tag/v30.1.1), including changing the logger it uses to `com.google.common.base.Preconditions`. - `base`: Deprecated `StandardSystemProperty.JAVA_EXT_DIRS`. We do not plan to remove the API, but note that, under recent versions of Java, that property always has a value of `null`. ([38abf07](google/guava@38abf07)) - `net`: Added `HttpHeaders` constants for `Origin-Isolation` and `X-Request-ID`. ([a48fb4f](google/guava@a48fb4f), [8319d20](google/guava@8319d20)) - `reflect`: Added `ClassInfo.isTopLevel()`. ([4106272](google/guava@4106272)) - `util.concurrent`: Added `ClosingFuture.submitAsync(AsyncClosingCallable)`. ([c5e2d8d](google/guava@c5e2d8d)) - [Guava types can no longer be sent over GWT-RPC.](https://groups.google.com/d/msg/guava-announce/zHZTFg7YF3o/rQNnwdHeEwAJ) Even the earlier, temporary way to reenable support (`guava.gwt.emergency_reenable_rpc`) no longer has an effect. ([0cb89dd](google/guava@0cb89dd)) - `cache`: Fixed memory leak in `LocalCache` under [j2objc](https://developers.google.com/j2objc). ([5e519d9](google/guava@5e519d9)) - `collect`: Added two-element `min` and `max` methods to `Comparators`. ([958186c](google/guava@958186c)) - `collect`: Removed `@Beta` from `Multimaps.toMultimap`. ([b6b4dc4](google/guava@b6b4dc4)) - `collect`: Made the set returned by `ImmutableMap<K, V>.keySet()` serializable as long as `K` is serializable, even if `V` is not (and similarly for `values()`). ([f5a69c3](google/guava@f5a69c3)) - `collect`: Fixed bug in `powerSet.equals(otherPowerSet)` would erroneously return `false` if the two power sets' underlying sets were equal but had a different iteration order. ([215b1f0](google/guava@215b1f0)) - `collect`: Eliminated [j2objc](https://developers.google.com/j2objc) retain-cycle in `SingletonImmutableBiMap`. ([0ad38b8](google/guava@0ad38b8)) - `eventbus`: Prevented `@Subscribe` from being applied to a method that takes a primitive, as that will never be called. ([554546c](google/guava@554546c)) - `graph`: Made `Traverser.breadthFirst()` lazier, and optimized `Traverser` more generally. ([32f2d77](google/guava@32f2d77), [b5210ca](google/guava@b5210ca)) - `graph`: Added `@DoNotMock` to `Traverser`. ([6410f18](google/guava@6410f18)) - `io`: Deprecated `Files.createTempDir()`. ([fec0dbc](google/guava@fec0dbc)) ([CVE-2020-8908](https://nvd.nist.gov/vuln/detail/CVE-2020-8908); continuing discussion in [#4011](google/guava#4011)) - `io`: Upgraded `ByteStreams.copy(InputStream, OutputStream)` to use the faster `FileChannel` if possible. ([a1e9a0b](google/guava@a1e9a0b)) [update: My mistake: This was [rolled back](google/guava@e839f94), so it did not make 30.0.] - `math`: Added `roundToDouble` to `BigDecimalMath`, `BigIntegerMath`, and `LongMath`. ([bee4f3c](google/guava@bee4f3c), [2b5c096](google/guava@2b5c096), [633abf2](google/guava@633abf2)) - `net`: Added `MediaType` constants for several font/ types. ([571cf66](google/guava@571cf66)) - `net`: Added `HttpHeaders` constants for `Cross-Origin-Embedder-Policy(-Report-Only)?`. ([c3bf731](google/guava@c3bf731)) - `testing`: Made `EqualsTester` test that non-`String` objects are not equal to their `String` representations. ([c9570ea](google/guava@c9570ea)) - `util.concurrent`: Added `ClosingFuture`. ([52e048e](google/guava@52e048e)) - `util.concurrent`: Removed the deprecated 1-arg `ServiceManager.addListener(Listener)`. Use the 2-arg `addListener(Listener, Executor)` overload, setting the executor to `directExecutor()` for equivalent behavior. ([dfb0001](google/guava@dfb0001)) - `util.concurrent`: Changed `AbstractFuture.toString()` to no longer include the `toString()` of the result. ([2ebf27f](google/guava@2ebf27f)) - `util.concurrent`: Added `awaitTerminationUninterruptibly`. ([f07b954](google/guava@f07b954))
As of 31.0, it no longer does. Relevant to #5269 RELNOTES=n/a PiperOrigin-RevId: 399327005
As of 31.0, it no longer does. Relevant to #5269 RELNOTES=n/a PiperOrigin-RevId: 399330047
…e remaining guava-android sources (mostly testing utilities). guava-android was using `@CheckForNull` because it couldn't use type-use annotations when it targeted Java 7. Now that [it's built with `-source 8 -target 8`](#5269), we can use type-use annotations. RELNOTES=n/a PiperOrigin-RevId: 522310996
…e remaining guava-android sources (mostly testing utilities). guava-android was using `@CheckForNull` because it couldn't use type-use annotations when it targeted Java 7. Now that [it's built with `-source 8 -target 8`](#5269), we can use type-use annotations. RELNOTES=n/a PiperOrigin-RevId: 524912499
Currently, our "Android" flavor of Guava supports 2 use cases:
We are definitely not going to start using Java 8 APIs. Thus, we are not going to increase our minimum Android version to 24, nor are we going to require our users to enable library desugaring. In short: We'll continue to support older versions of Android with no changes on users' part.
However, we are investigating whether to stop supporting non-Android users who use Java 7. This would let us simplify some implementations (mainly by using lambdas), but more importantly, it would let us make some API improvements -- like
default
methods on interfaces and type annotations (such as for nullness).This is part of a larger effort by many Google projects to consider dropping support for Java 7. Please let us know if you anticipate problems from this change -- mainly, if you are using Guava in your library or app and you support Java 7. Thanks.
(Please also spread the word. I will additionally announce this on our mailing list. Later, we may also try to introduce some warnings when Guava is run under Java 7.)
The text was updated successfully, but these errors were encountered: