blob: a17472386544921daa8b0a46e61f50f3bc341327 [file] [log] [blame]
clementberaa14f58b2019-04-29 10:58:16 +02001// 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
clementberabe19d302019-05-23 17:23:21 +02005package nesthostexample;
clementberaa14f58b2019-04-29 10:58:16 +02006
7public class BasicNestHostWithInnerClassFields {
8
clementbera9f34f402019-05-08 15:22:47 +02009 private String fieldWithoutBridge = "noBridge";
clementberaa14f58b2019-04-29 10:58:16 +020010 private String field = "field";
11 private static String staticField = "staticField";
12
13 @SuppressWarnings("static-access") // we want to test that too.
14 public String accessNested(BasicNestedClass o) {
clementbera2a268732019-05-02 09:22:32 +020015 o.field = "RW" + o.field;
16 o.staticField = "RW" + o.field;
clementbera9f34f402019-05-08 15:22:47 +020017 return o.field + o.staticField + BasicNestedClass.staticField + fieldWithoutBridge;
clementberaa14f58b2019-04-29 10:58:16 +020018 }
19
20 public static class BasicNestedClass {
21
22 private String field = "nestField";
23 private static String staticField = "staticNestField";
24
25 @SuppressWarnings("static-access") // we want to test that too.
26 public String accessOuter(BasicNestHostWithInnerClassFields o) {
clementbera2a268732019-05-02 09:22:32 +020027 o.field = "RW" + o.field;
28 o.staticField = "RW" + o.field;
clementberaa14f58b2019-04-29 10:58:16 +020029 return o.field + o.staticField + BasicNestedClass.staticField;
30 }
31 }
32
33 public static void main(String[] args) {
34 BasicNestHostWithInnerClassFields outer = new BasicNestHostWithInnerClassFields();
35 BasicNestedClass inner = new BasicNestedClass();
36
37 System.out.println(outer.accessNested(inner));
38 System.out.println(inner.accessOuter(outer));
39 }
40}