Debian Codegraph @

src/com/google/errorprone/annotations/MustBeClosed.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /*
2 * Copyright 2016 The Error Prone 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.errorprone.annotations;
18
19 import static java.lang.annotation.ElementType.CONSTRUCTOR;
20 import static java.lang.annotation.ElementType.METHOD;
21
22 import java.lang.annotation.Documented;
23 import java.lang.annotation.Target;
24
25 /**
26 * Annotation for constructors of AutoCloseables or methods that return an AutoCloseable and require
27 * that the resource is closed.
28 *
29 * <p>This is enforced by checking that invocations occur within the resource variable initializer
30 * of a try-with-resources statement, which guarantees that the resource is always closed. The
31 * analysis may be improved in the future to recognize other patterns where the resource will always
32 * be closed.
33 *
34 * <p>Note that Android SDK versions prior to 19 do not support try-with-resources, so the
35 * annotation should be avoided on APIs that may be used on Android, unless desugaring is used.
36 */
37 @Documented
38 @Target({CONSTRUCTOR, METHOD})
39 public @interface MustBeClosed {}