File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
spring-core/src/test/java/org/springframework Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -75,4 +75,7 @@ public int compareTo(Object o) {
75
75
return 1 ;
76
76
}
77
77
}
78
+
79
+ public static class NestedObject {
80
+ }
78
81
}
Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ void forName() throws ClassNotFoundException {
86
86
assertThat (ClassUtils .forName ("org.springframework.tests.sample.objects.TestObject[][]" , classLoader )).isEqualTo (TestObject [][].class );
87
87
assertThat (ClassUtils .forName (TestObject [][].class .getName (), classLoader )).isEqualTo (TestObject [][].class );
88
88
assertThat (ClassUtils .forName ("[[[S" , classLoader )).isEqualTo (short [][][].class );
89
+ assertThat (ClassUtils .forName ("org.springframework.tests.sample.objects.TestObject$NestedObject" , classLoader )).isEqualTo (TestObject .NestedObject .class );
90
+ assertThat (ClassUtils .forName ("org.springframework.tests.sample.objects.TestObject.NestedObject" , classLoader )).isEqualTo (TestObject .NestedObject .class );
89
91
}
90
92
91
93
@ Test
Original file line number Diff line number Diff line change @@ -641,15 +641,13 @@ You can use the `Class` property in one of two ways:
641
641
642
642
****
643
643
.Inner class names
644
- If you want to configure a bean definition for a `static` nested class, you have to use
645
- the binary name of the nested class.
644
+ If you want to configure a bean definition for a `static` nested class, you may use
645
+ either binary name of the nested class or separate it with dot .
646
646
647
647
For example, if you have a class called `SomeThing` in the `com.example` package, and this
648
- `SomeThing` class has a `static` nested class called `OtherThing`, the value of the `class`
649
- attribute on a bean definition would be `com.example.SomeThing$OtherThing`.
650
-
651
- Notice the use of the `$` character in the name to separate the nested class name from
652
- the outer class name.
648
+ `SomeThing` class has a `static` nested class called `OtherThing`, they can be separated
649
+ by a dollar (`$`) or dot (`.`). So the value of the `class` attribute on a bean definition
650
+ would be `com.example.SomeThing$OtherThing` or `com.example.SomeThing.OtherThing`.
653
651
****
654
652
655
653
You can’t perform that action at this time.
0 commit comments