Note that there are some explanatory texts on larger screens.

plurals
  1. POWarnings "unchecked call" and "unchecked conversion"
    text
    copied!<p><strong>When I compile my code I get 4 warnings - but how do I make them disappear?</strong> (and I don't mean with @SuppressWarnings)</p> <p>PS: Obviously this must have been asked before - but either I cannot find it or I cannot apply it.</p> <hr> <p><em><strong>Output</em></strong></p> <pre><code>warning: [unchecked] unchecked call to BaseWorker(C) as a member of the raw type BaseWorker [warn] return new BaseWorker(this); warning: [unchecked] unchecked conversion [warn] found : com.crashnote.BaseWorker [warn] required: com.crashnote.BaseWorker&lt;C&gt; [warn] return new BaseWorker(this); warning: [unchecked] unchecked call to SubWorker(C) as a member of the raw type SubWorker [warn] return new SubWorker(this); warning: [unchecked] unchecked conversion [warn] found : com.crashnote.SubWorker [warn] required: com.crashnote.SubWorker&lt;C&gt; [warn] return new SubWorker(this); </code></pre> <hr> <p><em><strong>Source Code</em></strong></p> <p><strong>BaseConfig</strong>: instantiates <em>BaseWorker</em></p> <pre><code>public class BaseConfig&lt;C extends BaseConfig&gt; { public BaseConfig(final Object c) { } public BaseWorker&lt;C&gt; getWorker() { return new BaseWorker(this); } } </code></pre> <p><strong>BaseWorker</strong></p> <pre><code>public class BaseWorker&lt;C extends BaseConfig&gt; { public BaseWorker(final C config) { } } </code></pre> <p><strong>SubConfig</strong>: instantiates <em>SubWorker</em></p> <pre><code>class SubConfig&lt;C extends SubConfig&gt; extends BaseConfig&lt;C&gt; { public SubConfig(final Object c) { super(c); } @Override public SubWorker&lt;C&gt; getWorker() { return new SubWorker(this); } } </code></pre> <p><strong>SubWorker</strong>: inherits from SubWorker</p> <pre><code>public class SubWorker&lt;C extends BaseConfig&gt; extends BaseWorker&lt;C&gt; { public SubWorker(final C config) { super(config); } } </code></pre> <hr> <p><em><strong>Edit</em></strong></p> <p>I tried the provided solutions but for some reason it fails now.</p> <p><strong>A)</strong></p> <pre><code>return new BaseWorker&lt;BaseConfig&gt;(this); </code></pre> <p>results in</p> <pre><code>incompatible types [error] found : BaseWorker&lt;BaseConfig&gt; [error] required: BaseWorker&lt;C&gt; [error] return new BaseWorker&lt;BaseConfig&gt;(this); </code></pre> <p><strong>B)</strong></p> <pre><code>return new BaseWorker&lt;C&gt;(this); </code></pre> <p>results in</p> <pre><code>cannot find symbol [error] symbol : constructor BaseWorker(BaseConfig&lt;C&gt;) [error] location: class BaseWorker&lt;C&gt; [error] return new BaseWorker&lt;C&gt;(this); </code></pre> <p>Hm, maybe I'm doing something wrong. This is Java 6 by the way, in case it matters.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload