Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | // Copyright (c) 2016, 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 | |
| 5 | // This code is not run directly. It needs to be compiled to dex code. |
| 6 | // 'throwing.dex' is what is run. |
| 7 | |
| 8 | package throwing; |
| 9 | |
| 10 | import java.util.ArrayList; |
| 11 | import java.util.LinkedList; |
| 12 | import java.util.List; |
| 13 | |
| 14 | /** |
| 15 | * This class' logic is completely bogus. The only purpose is to be recursive to avoid inlining |
| 16 | * and terminate. |
| 17 | */ |
| 18 | public class RenamedClass { |
| 19 | public List list = new ArrayList(); |
| 20 | |
| 21 | public List getList() { |
| 22 | if (list == null) { // always false |
| 23 | setList(getList()); |
| 24 | } |
| 25 | return list; |
| 26 | } |
| 27 | |
| 28 | public void setList(List list) { |
| 29 | if (list == null) { |
| 30 | setList(new LinkedList()); |
| 31 | } else { |
| 32 | this.list = list; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // Another method with the same signature as getList |
| 37 | public void swap(List list) { |
| 38 | List before = getList(); |
| 39 | setList(list); |
| 40 | if (before == null) { // always false |
| 41 | swap(list); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | static RenamedClass create() { |
| 46 | RenamedClass theClass = new RenamedClass(); |
| 47 | theClass.setList(new LinkedList()); |
| 48 | return theClass; |
| 49 | } |
| 50 | |
| 51 | void takeThingsForASpin(int value) { |
| 52 | if (value == 42) { |
| 53 | swap(new LinkedList<>()); |
| 54 | setList(getList()); |
| 55 | } else { |
| 56 | takeThingsForASpin(42); |
| 57 | } |
| 58 | } |
| 59 | } |