Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | /** |
| 18 | * Check that the classes using publicly listed APIS are verified. |
| 19 | */ |
| 20 | |
| 21 | class AccessPublicCtor { |
| 22 | public Integer foo() { |
| 23 | return new Integer(1); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | class AccessPublicMethod { |
| 28 | public double foo(Integer i) { |
| 29 | return i.doubleValue(); |
| 30 | } |
| 31 | } |
| 32 | |
Cole Faust | 4d8fea0 | 2022-10-15 21:33:27 -0700 | [diff] [blame] | 33 | @SuppressWarnings("LockOnBoxedPrimitive") |
Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 34 | class AccessPublicMethodFromParent { |
| 35 | public void foo(Integer i) { |
| 36 | i.notify(); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | class AccessPublicStaticMethod { |
| 41 | public Integer foo() { |
| 42 | return Integer.getInteger("1"); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | class AccessPublicStaticField { |
| 47 | public int foo() { |
| 48 | return Integer.BYTES; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Check that the classes using non publicly listed APIS are not verified. |
| 54 | */ |
| 55 | |
| 56 | class AccessNonPublicCtor { |
| 57 | public Integer foo() { |
| 58 | return new Integer("1"); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | class AccessNonPublicMethod { |
| 63 | public float foo(Integer i) { |
| 64 | return i.floatValue(); |
| 65 | } |
| 66 | } |
| 67 | |
Cole Faust | 4d8fea0 | 2022-10-15 21:33:27 -0700 | [diff] [blame] | 68 | @SuppressWarnings("LockOnBoxedPrimitive") |
Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 69 | class AccessNonPublicMethodFromParent { |
| 70 | public void foo(Integer i) { |
| 71 | i.notifyAll(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | class AccessNonPublicStaticMethod { |
| 76 | public Integer foo() { |
| 77 | return Integer.getInteger("1", 0); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | class AccessNonPublicStaticField { |
| 82 | public Class foo() { |
| 83 | return Integer.TYPE; |
| 84 | } |
| 85 | } |