Skip to content
New issue

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

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

Already on GitHub? # to your account

Objects.requireNonNull() generated in Java 6 mode #92

Closed
ben-manes opened this issue Mar 2, 2016 · 7 comments
Closed

Objects.requireNonNull() generated in Java 6 mode #92

ben-manes opened this issue Mar 2, 2016 · 7 comments

Comments

@ben-manes
Copy link

For some reason Java 7 method calls are being generated in Java 6 mode. This fails on a Samsung Galaxy Rugby phone which is Java 6 only. I am using Retrolambda v2.1.0, gradle-retrolambda v3.2.5, and the default (Java 6) configuration. I noticed when upgrading from v3.2.4 (with RL v2.0.6) that the older version generated many more usages of requireNonNull for other methods in that class file. I also tried installing JDK6 and setting JAVA6_HOME per the plugin, but that had no effect.

@ReactMethod
public void getCurrentPosition(Promise promise) {
  geolocation.getCurrentPosition(new WritableNativeMap(),
      promise::resolve, (any) -> promise.reject(""));
}
public void getCurrentPosition(com.facebook.react.bridge.Promise);
  Code:
     0: aload_0
     1: getfield      #38                 // Field geolocation:Lcom/convoy/loaddoc/geolocation/GeolocationReactModule;
     4: new           #73                 // class com/facebook/react/bridge/WritableNativeMap
     7: dup
     8: invokespecial #76                 // Method com/facebook/react/bridge/WritableNativeMap."<init>":()V
    11: aload_1
    12: dup
    13: invokestatic  #268                // Method java/util/Objects.requireNonNull:(Ljava/lang/Object;)Ljava/lang/Object;
    16: pop
    17: invokestatic  #274                // Method com/convoy/loaddoc/camera2/view/DocumentCreatorReactModule$$Lambda$1.lambdaFactory$:(Lcom/facebook/react/bridge/Promise;)Lcom/facebook/react/bridge/Callback;
    20: aload_1
    21: invokestatic  #277                // Method com/convoy/loaddoc/camera2/view/DocumentCreatorReactModule$$Lambda$2.lambdaFactory$:(Lcom/facebook/react/bridge/Promise;)Lcom/facebook/react/bridge/Callback;
    24: invokevirtual #280                // Method com/convoy/loaddoc/geolocation/GeolocationReactModule.getCurrentPosition:(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
    27: return

Do you have any suggestions for resolving this? If not, I'll have to remove retrolambda for the next release, which would be a bummer.

@JakeWharton
Copy link
Contributor

Dupe of #75?

@ben-manes
Copy link
Author

Isn't that one regarding JDK9 behavior and its rewriting behavior? I'm running oracle64-1.8.0.51, though perhaps they back ported that change?

@JakeWharton
Copy link
Contributor

Perhaps backported, yes. Empirically it seems like the same thing.

@ben-manes
Copy link
Author

Actually, that leads to an error-prone bug which is introduces the requireNonNull for target >= 1.7. When I use regular javac the byte code is correct. So it sounds like the resolution is to not use error-prone on Android builds (@cushon).

@ben-manes
Copy link
Author

Closing as disabling error prone until #75 is resolved.

@JakeWharton
Copy link
Contributor

I would call that a temporary workaround, notba resolution. error-prone is
the bees knees!

On Wed, Mar 2, 2016, 4:34 PM Ben Manes notifications@github.com wrote:

Actually, that leads to an error-prone bug
google/error-prone#375 which is introduces
the requireNonNull for target >= 1.7. When I use regular javac the byte
code is correct. So it sounds like the resolution is to not use error-prone
on Android builds (@cushon https://github.com/cushon).


Reply to this email directly or view it on GitHub
#92 (comment)
.

@cushon
Copy link
Contributor

cushon commented Mar 3, 2016

The JDK 9 javac emits requireNonNull for -source >= 7, and Error Prone uses the JDK 9 javac even if it's running on JDK 8.

I opened #93 to fix Retrolambda.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants