1 /* 2 * Copyright (C) 2015 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.base; 18 19 import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 20 import static java.lang.annotation.ElementType.CONSTRUCTOR; 21 import static java.lang.annotation.ElementType.FIELD; 22 import static java.lang.annotation.ElementType.METHOD; 23 import static java.lang.annotation.ElementType.TYPE; 24 import static java.lang.annotation.RetentionPolicy.CLASS; 25 26 import com.google.common.annotations.GwtCompatible; 27 import java.lang.annotation.Retention; 28 import java.lang.annotation.Target; 29 30 /** 31 * Signifies that a test should not be run under Android. This annotation is respected only by our 32 * Google-internal Android suite generators. Note that those generators also suppress any test 33 * annotated with LargeTest. 34 * 35 * <p>Why use a custom annotation instead of {@code androidx.test.filters.Suppress}? I'm not 36 * completely sure that this is the right choice, but it has various advantages: 37 * 38 * <ul> 39 * <li>An annotation named just "Suppress" might someday be treated by a non-Android tool as a 40 * suppression. This would follow the precedent of many of our annotation processors, which 41 * look for any annotation named, e.g., "GwtIncompatible," regardless of package. 42 * <li>An annotation named just "Suppress" might suggest to users that the test is suppressed 43 * under all environments. We could fight this by fully qualifying the annotation, but the 44 * result will be verbose and attention-grabbing. 45 * <li>We need to be careful about how we suppress {@code suite()} methods in {@code common.io}. 46 * The generated suite for {@code FooTest} ends up containing {@code FooTest} itself plus some 47 * other tests. We want to exclude the other tests (which Android can't handle) while 48 * continuing to run {@code FooTest} itself. This is exactly what happens with {@code 49 * AndroidIncompatible}. But I'm not sure what would happen if we annotated the {@code 50 * suite()} method with {@code Suppress}. Would {@code FooTest} itself be suppressed, too? 51 * <li>In at least one case, a use of {@code sun.misc.FpUtils}, the test will not even 52 * <i>compile</i> against Android. Now, this might be an artifact of our build system, one 53 * that we could probably work around. Or we could manually strip the test from open-source 54 * Guava while continuing to run it internally, as we do with many other tests. This would 55 * suffice because we our Android users and tests are using the open-source version, which 56 * would no longer have the problematic test. But why bother when we can instead strip it with 57 * a more precisely named annotation? 58 * <li>While a dependency on Android ought to be easy if it's for annotations only, it will 59 * probably require adding the dep to various ACLs, license files, and Proguard 60 * configurations, and there's always the potential that something will go wrong. It 61 * <i>probably</i> won't, since the deps are needed only in tests (and maybe someday in 62 * testlib), but why bother? 63 * <li>Stripping code entirely might help us keep under the method limit someday. Even if it never 64 * comes to that, it may at least help with build and startup times. 65 * </ul> 66 */ 67 @Retention(CLASS) 68 @Target({ANNOTATION_TYPE, CONSTRUCTOR, FIELD, METHOD, TYPE}) 69 @GwtCompatible 70 @interface AndroidIncompatible {} 71