Stephan Herhut | 7fa3d1b | 2017-08-04 13:30:15 +0200 | [diff] [blame] | 1 | // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | package inlining.pkg; |
| 5 | |
| 6 | import inlining.CheckDiscarded; |
| 7 | |
| 8 | public class PublicClass { |
| 9 | |
| 10 | protected static String protectedMethod() { |
| 11 | return "Hello"; |
| 12 | } |
| 13 | |
| 14 | @CheckDiscarded |
| 15 | static String callsProtectedMethod() { |
| 16 | return protectedMethod(); |
| 17 | } |
| 18 | |
| 19 | @CheckDiscarded |
| 20 | static String callsProtectedMethod2() { |
| 21 | return protectedMethod(); |
| 22 | } |
| 23 | |
| 24 | public static String callsProtectedMethod3() { |
| 25 | return protectedMethod(); |
| 26 | } |
| 27 | |
| 28 | static String packagePrivateMethod() { |
| 29 | return "World"; |
| 30 | } |
| 31 | |
| 32 | @CheckDiscarded |
| 33 | static int readsPackagePrivateField() { |
| 34 | return PackagePrivateClass.aField; |
| 35 | } |
| 36 | |
| 37 | public static int alsoReadsPackagePrivateField() { |
| 38 | return PackagePrivateClass.aField; |
| 39 | } |
| 40 | |
| 41 | @CheckDiscarded |
| 42 | public static String callsPackagePrivateMethod() { |
| 43 | return packagePrivateMethod(); |
| 44 | } |
| 45 | |
| 46 | public static String alsoCallsPackagePrivateMethod() { |
| 47 | return packagePrivateMethod(); |
| 48 | } |
| 49 | |
| 50 | public static void callMeToPreventInling() { |
| 51 | // Call it three times so it does not get inlined. |
| 52 | packagePrivateMethod(); |
| 53 | packagePrivateMethod(); |
| 54 | packagePrivateMethod(); |
| 55 | protectedMethod(); |
| 56 | protectedMethod(); |
| 57 | protectedMethod(); |
| 58 | } |
| 59 | } |