No, this is no problem at all, especially not at human readable levels like yours.
Let's look at the limits, though. Code like this:
public class Foo {
public Foo(Foo f) {}
public static void main(String[] args) {
new Foo(new Foo(new Foo(new Foo(null))));
}
}
compiles into:
public static void main(java.lang.String[]);
Code:
0: new #2 // class Foo
3: dup
4: new #2 // class Foo
7: dup
8: new #2 // class Foo
11: dup
12: new #2 // class Foo
15: dup
16: aconst_null
17: invokespecial #3 // Method "<init>":(LFoo;)V
20: invokespecial #3 // Method "<init>":(LFoo;)V
23: invokespecial #3 // Method "<init>":(LFoo;)V
26: invokespecial #3 // Method "<init>":(LFoo;)V
29: pop
30: return
i.e. for each nesting, it just uses two or more elements on the operand stack: the class to instantiate, the nested object, and any other variables passed along with it.
The maximum size of the operand stack is implementation specific, but any JVM will certainly be able to hold several thousand variables and operate on them with efficiency. For comparison, javac
crashes after just 1000 nesting.
So no, your four level deep nesting is absolutely no problem for the JVM.