<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Runtime type checking contradicts compile time type declarations in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078189#M2406</link>
    <description>&lt;P&gt;I could explain the errors you are getting here, but I do think its worth you explaining what you are trying to do in your app and the data sources you are working with.&amp;nbsp; Once I've understood what you are trying to do and what data you are working with I can give you pointers to documentation or samples which demonstrate this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 10:10:07 GMT</pubDate>
    <dc:creator>MarkBaird</dc:creator>
    <dc:date>2021-07-13T10:10:07Z</dc:date>
    <item>
      <title>Runtime type checking contradicts compile time type declarations</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078149#M2401</link>
      <description>&lt;P&gt;In trying to circumvent another problem I tried creating a FeatureLayer via its FeatureLayer(FeatureTable) constructor. FeatureCollectionTable is a subclass of FeatureTable and yet passing one as the argument to the above constructor results in an exception being thrown. Why?&lt;/P&gt;&lt;P&gt;"Cannot create a feature layer from a feature collection table. Add the feature collection table to a feature collection."&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 06:57:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078149#M2401</guid>
      <dc:creator>DaveWhitla</dc:creator>
      <dc:date>2021-07-13T06:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime type checking contradicts compile time type declarations</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078189#M2406</link>
      <description>&lt;P&gt;I could explain the errors you are getting here, but I do think its worth you explaining what you are trying to do in your app and the data sources you are working with.&amp;nbsp; Once I've understood what you are trying to do and what data you are working with I can give you pointers to documentation or samples which demonstrate this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 10:10:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078189#M2406</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2021-07-13T10:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime type checking contradicts compile time type declarations</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078192#M2407</link>
      <description>&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;I believe I understand the error. My issue with it is that an implementation should not impose runtime type restrictions on a method argument that satisfies the declared type of the method parameter.&lt;/P&gt;&lt;P&gt;Either the method should take some more restrictive subclass of FeatureTable (or another marker interface) as its parameter, or FeatureCollectionTable should not extend FeatureTable.&lt;/P&gt;&lt;P&gt;That said I think I have found another way around my problem. My objective was to set LabelDefinitions on a FeatureCollectionLayer and up to that point I had hit a few dead ends and was trying to find an alternative way of constructing a FeatureLayer. Upon finding that particular method to be another dead end I moved on to finding some way of accessing the FeatureLayer(s) created within the FeatureCollectionLayer. I ran into another issue there documented in another post today but through trial and error probing the available methods on FeatureCollectionLayer I have found that the following, while it feels a bit clunky, seems to consistently work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;FeatureCollection featureCollection = new FeatureCollection();
featureCollection.getTables().add(table);
layer = new FeatureCollectionLayer(featureCollection);

layer.getSubLayerContents().addListChangedListener(event -&amp;gt; {
  if (event.getAction() == ListChangedEvent.Action.ADDED) {
    for (LayerContent layerContent : event.getItems()) {
      if (layerContent instanceof FeatureLayer featureLayer) {
        featureLayer.setLabelsEnabled(true);
        featureLayer.getLabelDefinitions().add(getLabelDefinition());  
      }
    }
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 10:27:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078192#M2407</guid>
      <dc:creator>DaveWhitla</dc:creator>
      <dc:date>2021-07-13T10:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime type checking contradicts compile time type declarations</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078221#M2408</link>
      <description>&lt;P&gt;I suspect the issue you have been seeing is that your application is trying to access resources before they are loaded.&amp;nbsp; In the Runtime SDK we encourage asynchronous development techniques to ensure that you don't write any code which potentially blocks the UI thread of your app.&amp;nbsp; I'd have a look at this page on &lt;A href="https://developers.arcgis.com/java/programming-patterns/loadable/" target="_self"&gt;loadable&lt;/A&gt; resources.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your code above I suspect something in your app has triggered a load event because the ListChangesListener has triggered.&amp;nbsp; This may have been caused by you adding the layer to the map, or you called LoadAsync on the layer.&lt;/P&gt;&lt;P&gt;Anyway I've added a snipped of code to set the labelling property within a doneLoadListener.&amp;nbsp; If you call this outside of the listener it throws an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;      featureCollectionLayer.loadAsync(); // needed if you didn't add it to a map.
      featureCollectionLayer.addDoneLoadingListener(()-&amp;gt; {
        System.out.println("loaded");
        // if this is called without the layer loaded it will fail.
        featureCollectionLayer.getLayers().get(0).setLabelsEnabled(false);
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This might be same issue with your other post.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:32:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078221#M2408</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2021-07-13T13:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime type checking contradicts compile time type declarations</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078241#M2409</link>
      <description>&lt;P&gt;This isn’t the issue I’m afraid. The bug in your code is definitely timing sensitive as I could only reproduce it sometimes. Under no circumstances should Iterator.hasNext() return true and the next call to Iterator.next() throw an index out of bounds exception.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 14:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078241#M2409</guid>
      <dc:creator>DaveWhitla</dc:creator>
      <dc:date>2021-07-13T14:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime type checking contradicts compile time type declarations</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078242#M2410</link>
      <description>&lt;P&gt;Thanks for the code suggestion. I already solved the issue using the code I provided above. I am not loading anything asynchronously - the table is populated locally.&lt;/P&gt;&lt;P&gt;Does simply adding a layer to the map's operationalLayers list trigger doneLoadingListeners if the layer is backed by a FeatureCollectionTable rather than a service call? If I had known that I might have tried it first, but honestly I think that listening for subLayerContents changes better reflects my aim as it will catch subsequent layer additions - if that is possible.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 15:34:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/runtime-type-checking-contradicts-compile-time/m-p/1078242#M2410</guid>
      <dc:creator>DaveWhitla</dc:creator>
      <dc:date>2021-07-13T15:34:42Z</dc:date>
    </item>
  </channel>
</rss>

