diff options
author | antoinebouchie <antoinebouchie@google.com> | 2018-10-27 17:23:45 -0700 |
---|---|---|
committer | Ron Shapiro <shapiro.rd@gmail.com> | 2018-10-29 12:43:38 -0400 |
commit | 47114df48e8a0b910e6cd1759b64c77dd8fdaee5 (patch) | |
tree | d6221a1911baea57bf57e84cc0522aa956b45b12 /value/src/test/java/com/google | |
parent | 46718eb7a68abfe824b5c19f7905e1d78e50c560 (diff) | |
download | auto-47114df48e8a0b910e6cd1759b64c77dd8fdaee5.tar.gz |
Check for null in autooneof.vm instead of calling foo.getClass() (in the case where one of the types is of type "Class", it triggers an "Error Prone" error: http://errorprone.info/bugpattern/GetClassOnClass
RELNOTES=n/a
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219005298
Diffstat (limited to 'value/src/test/java/com/google')
-rw-r--r-- | value/src/test/java/com/google/auto/value/processor/AutoOneOfCompilationTest.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/value/src/test/java/com/google/auto/value/processor/AutoOneOfCompilationTest.java b/value/src/test/java/com/google/auto/value/processor/AutoOneOfCompilationTest.java index d7dbe740..9de53ce9 100644 --- a/value/src/test/java/com/google/auto/value/processor/AutoOneOfCompilationTest.java +++ b/value/src/test/java/com/google/auto/value/processor/AutoOneOfCompilationTest.java @@ -70,12 +70,16 @@ public class AutoOneOfCompilationTest { " private AutoOneOf_TaskResult() {} // There are no instances of this type.", "", " static <V, T extends Throwable> TaskResult<V, T> value(V value) {", - " value.getClass();", + " if (value == null) {", + " throw new NullPointerException();", + " }", " return new Impl_value<V, T>(value);", " }", "", " static <V, T extends Throwable> TaskResult<V, T> exception(Throwable exception) {", - " exception.getClass();", + " if (exception == null) {", + " throw new NullPointerException();", + " }", " return new Impl_exception<V, T>(exception);", " }", "", |