[PSA] Java 8 coming to Chrome on Android

81 views
Skip to first unread message

Felix

unread,
Aug 15, 2017, 11:29:06 AM8/15/17
to Chromium-dev
Java development for Chrome on Android now supports Java 8 features such as lambdas, default interface methods, static interface methods, and try-with-resources statements (no need to guard with API level checks any more).

Currently, known limitations include:
1) Annotation @SuppressLint may not work properly with lambdas.
2) When checking in prebuilt Java jar/aar files, if the files have already been processed by Desugar, please add jar_excluded_patterns = [ "*ThrowableExtension*.class" ] to the build target. Example here.

Known issues include:
1) Android Studio 2.x may no longer work properly. Please use Android Studio 3 if necessary.

Andrew Grieve

unread,
Aug 15, 2017, 3:58:13 PM8/15/17
to F ., Chromium-dev
\o/

I'll also add that Felix has been going through and using Android Studio inspections to convert our code to use lambdas where applicable. It gets rid of quite a lot of boiler-plate! Thanks for seeing this through!

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAG8cArrUu_nzKrhzwWbYbaufUNZC9TQWg%3DS2S%3DV1HAYWf-9xww%40mail.gmail.com.

Bo Liu

unread,
Aug 17, 2017, 2:09:11 PM8/17/17
to agr...@chromium.org, F ., Chromium-dev
Question: is desugar doing another step of code transformation in addition to proguard? Would that have the potential to change up java stack source line numbers, and can the deobfuscation tool reverse that as well?

Andrew Grieve

unread,
Aug 17, 2017, 2:52:57 PM8/17/17
to bo...@chromium.org, Andrew Grieve, F ., Chromium-dev
Hmm, good question indeed. Here's an example stack trace where I've added to setPrivateDataDirectorySuffix():
            Runnable r = () -> {
              throw new RuntimeException("What will this do?");
            };
            r.run();

08-17 14:47:58.736  7135  7135 E AndroidRuntime: Caused by: java.lang.RuntimeException: What will this do?
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.base.PathUtils.lambda$setPrivateDataDirectorySuffix$0$PathUtils(PathUtils.java:134)
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.base.PathUtils$$Lambda$0.run(Unknown Source:0)
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.base.PathUtils.setPrivateDataDirectorySuffix(PathUtils.java:136)
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.chrome.browser.init.ChromeBrowserInitializer.preInflationStartup(ChromeBrowserInitializer.java:211)
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.chrome.browser.init.ChromeBrowserInitializer.handlePreNativeStartup(ChromeBrowserInitializer.java:161)
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.chrome.browser.init.AsyncInitializationActivity.onCreateInternal(AsyncInitializationActivity.java:283)
08-17 14:47:58.736  7135  7135 E AndroidRuntime: at org.chromium.chrome.browser.init.AsyncInitializationActivity.onCreate(AsyncInitializationActivity.java:243)

Bo Liu

unread,
Aug 17, 2017, 2:58:08 PM8/17/17
to Andrew Grieve, F ., Chromium-dev
I assume r.run() is line 136? So looks fine for that case

Andrew Grieve

unread,
Aug 17, 2017, 3:20:13 PM8/17/17
to bo...@chromium.org, Andrew Grieve, F ., Chromium-dev
On Thu, Aug 17, 2017 at 2:56 PM, Bo Liu <bo...@chromium.org> wrote:
I assume r.run() is line 136? So looks fine for that case
Yes. 
Reply all
Reply to author
Forward
0 new messages