Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does Java generate signatures for Methods?
    text
    copied!<p>I have an Java class with a static final method getAll:</p> <pre><code>public static final Vector&lt;Category&gt; getAll(Context context, ContentValues where) { ArrayList&lt;Integer&gt; IDs = null; if(where != null &amp;&amp; where.containsKey(DatabaseAdapter.KEY_PRODUCT)) { IDs = OvertureItem.getAll(context, DatabaseAdapter.TABLE_PRODUCT_CATEGORY, new String[] { DatabaseAdapter.KEY_CATEGORY }, where); } else { IDs = OvertureItem.getAll(context, DatabaseAdapter.TABLE_CATEGORIES, where); } Vector&lt;Category&gt; categories = new Vector&lt;Category&gt;(); for(Integer id: IDs) { categories.add(Category.get(context, id)); } return categories; } </code></pre> <p>Now I want to hand in null as a value for the where statemant so that it will just be ignored later on in the code. Anyway in the testcase for this method I have:</p> <pre><code>Vector&lt;Category&gt; categories = Category.getAll(context, null); </code></pre> <p>Which then in turn gives me a <strong>NoSuchMethodError</strong>. I don't know exactly why it does that. The only thing I could imagine is that the null I hand in would not match the signature of the above method. But how can I overcome this? I already thought of overloading. But this would just end in rewriting most of the code. At least when I do it, how I think. </p> <p>Any suggestions on that?</p> <p>Phil</p> <p>P.S. This is the stack trace I get:</p> <pre><code>java.lang.NoSuchMethodError: com.sap.catalogue.model.Category.getAll at com.sap.overture.test.model.CategoryTest.testGetAll(CategoryTest.java:59) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447) </code></pre>
 

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