title: Java object initialization with diamond operator terrible javac compile time performance
body: <p>I'm using the diamond operator to initiate objects within a list. However as the number of array objects increases, compile time increases from few seconds to hours. My eclipse auto build made my eclipse non-responsive. I then noticed it is a javac issue. When I replace all <code>&lt;&gt;</code> with <code>&lt;String, List&lt;Category&gt;&gt;</code> the compile time goes back to just a few seconds. Is this something I'm doing wrong or is it just a Java performance issue?</p>
  
  <p>Here is my code which will take Java hours to compile (or crashes javac v8u25):</p>
  
  <pre><code>    List&lt;Pair&lt;String, List&lt;Category&gt;&gt;&gt; categoryMappings = null;
  
      public void reloadStaticData() {                  
        // Left one is the provider's category and right one is ours
        try(UoW luow = CoreModule.getInstance(UoW.class)) {
          CategoryRepo categoryRepo = luow.getCategoryRepo();
          categoryMappings = Arrays.asList(
  
                    // Nightlife
                    new ImmutablePair&lt;&gt;("Bars", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get())),
                    new ImmutablePair&lt;&gt;("Ski-Bar", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get())),
                    new ImmutablePair&lt;&gt;("Bar", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get())),
                    new ImmutablePair&lt;&gt;("Beer", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get())),
                    new ImmutablePair&lt;&gt;("Pubs", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get())),
                    new ImmutablePair&lt;&gt;("Clubs", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get())),
                    new ImmutablePair&lt;&gt;("Dance", Arrays.asList(categoryRepo.findByName("Bar &amp; Pubs").get()
                            ,categoryRepo.findByName("Clubs").get())),    
                    // if I got more than 20 of these ImmutablePairs, javac crashes or takes hours to compile
        );
        }
      }
  </code></pre>
  
  <p><strong><em>Edit:</em></strong> 
  As Sotirios mentioned in comments it seems to be a reported issue in JDK:</p>
  
  <p><em>type inference exponential compilation performance:</em>
  <a href="https://bugs.openjdk.java.net/browse/JDK-8055984" rel="nofollow">https://bugs.openjdk.java.net/browse/JDK-8055984</a></p>
  
  <p><em>type inference performance regression:</em>
  <a href="https://bugs.openjdk.java.net/browse/JDK-8048838" rel="nofollow">https://bugs.openjdk.java.net/browse/JDK-8048838</a></p>