clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 1 | // Copyright (c) 2019, 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 | package nestHostExample; |
| 6 | |
| 7 | public class BasicNestHostWithInnerClassConstructors { |
| 8 | |
| 9 | public String field; |
| 10 | |
| 11 | private BasicNestHostWithInnerClassConstructors(String field) { |
| 12 | this.field = field; |
| 13 | } |
| 14 | |
clementbera | b0ff854 | 2019-05-09 14:37:10 +0200 | [diff] [blame] | 15 | private BasicNestHostWithInnerClassConstructors(int intVal) { |
| 16 | this.field = String.valueOf(intVal); |
| 17 | } |
| 18 | |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 19 | public static BasicNestedClass createNestedInstance(String field) { |
| 20 | return new BasicNestedClass(field); |
| 21 | } |
| 22 | |
| 23 | public static class BasicNestedClass { |
| 24 | |
| 25 | public String field; |
| 26 | |
| 27 | private BasicNestedClass(String field) { |
| 28 | this.field = field; |
| 29 | } |
| 30 | |
clementbera | 82a0f00 | 2019-05-20 09:43:12 +0200 | [diff] [blame] | 31 | private BasicNestedClass(String unused, String field, String alsoUnused) { |
| 32 | this.field = field + "UnusedConstructor"; |
| 33 | } |
| 34 | |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 35 | public static BasicNestHostWithInnerClassConstructors createOuterInstance(String field) { |
| 36 | return new BasicNestHostWithInnerClassConstructors(field); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | public static void main(String[] args) { |
| 41 | BasicNestHostWithInnerClassConstructors outer = BasicNestedClass.createOuterInstance("field"); |
| 42 | BasicNestedClass inner = |
| 43 | BasicNestHostWithInnerClassConstructors.createNestedInstance("nest1SField"); |
clementbera | b0ff854 | 2019-05-09 14:37:10 +0200 | [diff] [blame] | 44 | BasicNestHostWithInnerClassConstructors noBridge = |
| 45 | new BasicNestHostWithInnerClassConstructors(1); |
clementbera | 82a0f00 | 2019-05-20 09:43:12 +0200 | [diff] [blame] | 46 | BasicNestedClass unusedParamConstructor = |
| 47 | new BasicNestedClass("unused", "innerField", "alsoUnused"); |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 48 | |
| 49 | System.out.println(outer.field); |
| 50 | System.out.println(inner.field); |
clementbera | b0ff854 | 2019-05-09 14:37:10 +0200 | [diff] [blame] | 51 | System.out.println(noBridge.field); |
clementbera | 82a0f00 | 2019-05-20 09:43:12 +0200 | [diff] [blame] | 52 | System.out.println(unusedParamConstructor.field); |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 53 | } |
| 54 | } |