--
You received this message because you are subscribed to the Google Groups "java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/java/CAPCJOUqcLMWO41eQd%2BQEVmB7SxVQ1Y641E7hxUGqwhVuugEduQ%40mail.gmail.com.
R8 team has been working on optimizing enums -> ints for the past few months. I expect the optimization to land at some point this quarter. I think we should probably still just have no documentation on it for the interim, but then hopefully we can use them (in perhaps constrained ways).I'd probably still avoid them for now, since I'm skeptical they will be optimized to the point of ints (e.g. they might still require null checks to be put in here or there). So long as you're using constants, I don't think the extra type safety adds meaningfully more safety.@IntDef is supposed to be checked by android lint, and be more than just documentation. It's a bug if there's a case where it's not working. Note that in order to run lint now, you need to build an apk / module target rather than just an individual library target.On Mon, Jul 20, 2020 at 11:05 AM Bo Liu <bo...@chromium.org> wrote:Came up on this CL:Enum bloats the binary size and I don't believe that has changed. The rule for avoiding enums isn't actually written down however; at least I didn't find it when I tried.@IntDef afaict isn't actually type safe and is just serving as documentation. Eg this is an example where just passing an int into a @NetError and nothing seems to complain.
> @IntDef is supposed to be checked by android lint, and be more than just documentation. It's a bug if there's a case where it's not working. Note that in order to run lint now, you need to build an apk / module target rather than just an individual library target.Playing around with it locally, I can't get it to ever fail the build..On Mon, Jul 20, 2020 at 11:36 AM Andrew Grieve <agr...@chromium.org> wrote:R8 team has been working on optimizing enums -> ints for the past few months. I expect the optimization to land at some point this quarter. I think we should probably still just have no documentation on it for the interim, but then hopefully we can use them (in perhaps constrained ways).I'd probably still avoid them for now, since I'm skeptical they will be optimized to the point of ints (e.g. they might still require null checks to be put in here or there). So long as you're using constants, I don't think the extra type safety adds meaningfully more safety.@IntDef is supposed to be checked by android lint, and be more than just documentation. It's a bug if there's a case where it's not working. Note that in order to run lint now, you need to build an apk / module target rather than just an individual library target.On Mon, Jul 20, 2020 at 11:05 AM Bo Liu <bo...@chromium.org> wrote:Came up on this CL:Enum bloats the binary size and I don't believe that has changed. The rule for avoiding enums isn't actually written down however; at least I didn't find it when I tried.@IntDef afaict isn't actually type safe and is just serving as documentation. Eg this is an example where just passing an int into a @NetError and nothing seems to complain.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/java/CABiQX1XZCgrvz3F4R-8yp%3DqhuUB%2BfpfXRLycCgOi9urA-ncD6A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/java/CAA6XDjPOhPvLwC_z%2B37ZkfSt3Nv9PP2RhrCe_QF3Xc%3DGeFMBPQ%40mail.gmail.com.