Mathias Rav | f58b3ef | 2018-05-30 11:20:00 +0200 | [diff] [blame] | 1 | // Copyright (c) 2018, 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 shaking18; |
| 5 | |
| 6 | public class Shaking { |
| 7 | |
| 8 | public static void main(String[] args) { |
| 9 | int i = args.length; |
| 10 | run(i); |
| 11 | } |
| 12 | |
| 13 | private static void run(int i) { |
| 14 | // Three invocations of each method to avoid inlining. |
| 15 | Options o = |
| 16 | i % 2 == 0 ? getOptions(i % 3) : i % 5 == 0 ? getOptions(i % 7) : getOptions(i % 11); |
| 17 | print(make(o, i % 13)); |
| 18 | print(make(o, i % 17)); |
| 19 | print(make(o, i % 19)); |
| 20 | } |
| 21 | |
| 22 | private static Base make(Options o, int i) { |
| 23 | if (o.alwaysFalse) { |
| 24 | return new DerivedUnused(); |
| 25 | } |
| 26 | return o.dummy ? new Derived1() : new Derived2(); |
| 27 | } |
| 28 | |
| 29 | private static Options getOptions(int i) { |
| 30 | Options o = new Options(); |
| 31 | o.dummy = i % 101 < 23; |
| 32 | return o; |
| 33 | } |
| 34 | |
| 35 | private static void print(Base b) { |
| 36 | System.out.println(b.getMessage()); |
| 37 | } |
| 38 | } |