blob: a3fd5371d3c06e6d609795f515ab7a6fe140f1a9 [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001// 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
8package throwing;
9
10import java.util.ArrayList;
11import java.util.LinkedList;
12import 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 */
18public 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}