super(new Something(...)) is this construct wrong?
<p>I am looking at some java code where the constructor of a class looks like this:</p>

<pre><code>public class X extends ... {
    X(String s) {
       super(new Y(s)); 
    }
}
</code></pre>

<p>is that always wrong ? 
in other words is it creating an object in the constructor to pass it to 'super' always wrong ? if so why ?</p>

<p>EDIT: 
Why do I think it might be wrong ?</p>

<p>when creating a class X the first thing the jvm does is to call super on its super class. 
(that's done even if 'super()' is implied)
you can only do a limited amount of operations such as <code>super(new Y(s));</code> 
maybe a call to super with the ternary operator <code>super( s != null ? new Y(s) : new Y() )</code>
but you would not be able to put any more logic because super must be called first !!!
That's why I think it's wrong</p>
