1 /*
2 * MIT License
3 * Copyright (c) 2006-2025 JMockit developers
4 * See LICENSE file for full license text.
5 */
6 package integration.tests;
7
8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
10
11 /**
12 * The Class ClassWithNestedClasses.
13 */
14 public class ClassWithNestedClasses {
15
16 /** The logger. */
17 private static final Logger logger = LoggerFactory.getLogger(ClassWithNestedClasses.class);
18
19 /**
20 * The Class NestedClass.
21 */
22 public static class NestedClass {
23
24 /** The i. */
25 private final int i;
26
27 /**
28 * Instantiates a new nested class.
29 */
30 public NestedClass() {
31 i = 123;
32 }
33
34 /**
35 * The Class DeeplyNestedClass.
36 */
37 private static final class DeeplyNestedClass {
38
39 /**
40 * Prints the.
41 *
42 * @param text
43 * the text
44 */
45 void print(String text) {
46 logger.info(text);
47 }
48 }
49
50 /**
51 * The Class InnerClass.
52 */
53 private final class InnerClass {
54
55 /**
56 * Prints the.
57 *
58 * @param text
59 * the text
60 */
61 void print(String text) {
62 logger.info("{}: {}", text, i);
63 }
64 }
65 }
66
67 /**
68 * Do something.
69 */
70 public static void doSomething() {
71 new NestedClass.DeeplyNestedClass().print("test");
72
73 // Just so we have two paths:
74 if (logger != null) {
75 logger.info("Test");
76 }
77 }
78
79 /**
80 * Method containing anonymous class.
81 *
82 * @param i
83 * the i
84 *
85 * @return true, if successful
86 */
87 public static boolean methodContainingAnonymousClass(int i) {
88 new Cloneable() {
89 };
90 return i > 0;
91 }
92 }