1 /*
2  * Copyright 2019 The Android Open Source Project
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 @file:Suppress("deprecation")
18 
19 package sample.experimental
20 
21 import androidx.annotation.experimental.UseExperimental
22 import sample.experimental.foo.Bar
23 import sample.experimental.foo.ExperimentalPackage
24 
25 @Suppress("unused")
26 class UseJavaPackageFromKt {
27     /** Unsafe call into a class within an experimental package. */
callPackageUnsafenull28     fun callPackageUnsafe() {
29         val bar = Bar()
30         bar.baz()
31     }
32 
33     @ExperimentalPackage
callPackageExperimentalnull34     fun callPackageExperimental() {
35         val bar = Bar()
36         bar.baz()
37     }
38 
39     @UseExperimental(ExperimentalPackage::class)
callPackageUseExperimentalnull40     fun callPackageUseExperimental() {
41         val bar = Bar()
42         bar.baz()
43     }
44 
callSelfUnsafenull45     fun callSelfUnsafe() {
46         callPackageUnsafe()
47     }
48 
49     /** Unsafe call into an experimental method within this class. */
callSelfExperimentalnull50     fun callSelfExperimental() {
51         callPackageExperimental()
52     }
53 
callSelfUseExperimentalnull54     fun callSelfUseExperimental() {
55         callPackageUseExperimental()
56     }
57 }
58