You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Uwe Schindler <uw...@thetaphi.de> on 2015/05/09 12:29:56 UTC

RE: [JENKINS] Lucene-Solr-5.x-Linux (32bit/jdk1.9.0-ea-b54) - Build # 11848 - Failure!

Hi,

on the OpenJDK issue tracker this issue around the diamonds and type inference was discussed. It looks like we were relying on "legacy behavior" not specified in the JLS before Java 8. The Java 9 compiler therefore fixed the behavior to behave exactly like the Java 5, 6, 7 JLS defines how the type inference should happen. Lucene trunk compiled perfectly fine, because Java 8 redefined the type inference in the JLS and the bugs in previous compilers were fixed in Java 9. This also explains why we had issues when moving Trunk to Java 8, because with -source 1.8, the new type inference was used that caused some of our generics code to break. The new spec is more correct and the old legacy one is broken altogether!

https://bugs.openjdk.java.net/browse/JDK-8075793

Because it is unclear, how this issue is solved on the OpenJDK side, I would recommend to stay with the current fix, because those diamonds and type guessing by the compiler was always broken and error prone (my personal opinion). There also exist differences between Eclipse's compiler and JDK's and most of those differences are around this type of stuff.

I always hated diamonds and was always more happy with being explicit. So we should be more explicit in our code, if the type inference is not easy to explain - this is especially true for stuff where you have "<? extends Something>" and pass those as parameters around (and hope that the return type / diamond is correct) - which it isn't! I have nothing against diamongs in simple stuff like new "HashMap<>()", but as soon as you pass additional parameters around, it gets crazy.

In addition, the Eclipse ECJ compiler also seems to compile or understand this stuff in a different way, so it is really better to be explicit.

Thanks,
the Generics Policeman :-)

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Uwe Schindler [mailto:uwe@thetaphi.de]
> Sent: Thursday, March 19, 2015 5:29 PM
> To: dev@lucene.apache.org; rory.odonnell@oracle.com
> Cc: 'Dalibor Topic'; 'Balchandra Vaidya'
> Subject: RE: [JENKINS] Lucene-Solr-5.x-Linux (32bit/jdk1.9.0-ea-b54) - Build #
> 11848 - Failure!
> 
> Hi,
> 
> I opened Review ID: JI-9019884 "Java 9 b54 breaks compiling code with
> source/target 1.7 and diamond operator"
> 
> Uwe
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
> 
> 
> > -----Original Message-----
> > From: Rory O'Donnell [mailto:rory.odonnell@oracle.com]
> > Sent: Thursday, March 19, 2015 4:12 PM
> > To: Uwe Schindler; dev@lucene.apache.org
> > Cc: rory.odonnell@oracle.com; Dalibor Topic; Balchandra Vaidya
> > Subject: Re: [JENKINS] Lucene-Solr-5.x-Linux (32bit/jdk1.9.0-ea-b54) -
> > Build #
> > 11848 - Failure!
> >
> >
> > On 19/03/2015 14:30, Uwe Schindler wrote:
> > > Hi,
> > >
> > > this seems to be a bug (or feature?) in the most recent Java 9 build 54:
> > >
> > > compile-core:
> > >      [mkdir] Created dir: /home/jenkins/workspace/Lucene-Solr-5.x-
> > Linux/lucene/build/analysis/common/classes/java
> > >      [javac] Compiling 461 source files to
> > > /home/jenkins/workspace/Lucene-
> > Solr-5.x-Linux/lucene/build/analysis/common/classes/java
> > >      [javac] /home/jenkins/workspace/Lucene-Solr-5.x-
> > Linux/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/
> > Ch
> > arArrayMap.java:568: error: incompatible types: CharArrayMap<CAP#1>
> > cannot be converted to CharArrayMap<V>
> > >      [javac]     return new CharArrayMap<>(map, false);
> > >      [javac]            ^
> > >      [javac]   where V is a type-variable:
> > >      [javac]     V extends Object declared in method <V>copy(Map<?,?
> > extends V>)
> > >      [javac]   where CAP#1 is a fresh type-variable:
> > >      [javac]     CAP#1 extends V from capture of ? extends V
> > >
> > > This is the code:
> > >
> > >    @SuppressWarnings("unchecked")
> > >    public static <V> CharArrayMap<V> copy(final Map<?,? extends V>
> > > map)
> > {
> > >      if(map == EMPTY_MAP)
> > >        return emptyMap();
> > >      if(map instanceof CharArrayMap) {
> > >        CharArrayMap<V> m = (CharArrayMap<V>) map;
> > >        // use fast path instead of iterating all values
> > >        // this is even on very small sets ~10 times faster than iterating
> > >        final char[][] keys = new char[m.keys.length][];
> > >        System.arraycopy(m.keys, 0, keys, 0, keys.length);
> > >        final V[] values = (V[]) new Object[m.values.length];
> > >        System.arraycopy(m.values, 0, values, 0, values.length);
> > >        m = new CharArrayMap<>(m);
> > >        m.keys = keys;
> > >        m.values = values;
> > >        return m;
> > >      }
> > >      return new CharArrayMap<>(map, false);
> > >    }
> > >
> > > At least this breaks compiling existing code. Rory, should I open a
> > > bug
> > report with an example code?
> > Hi Uwe,
> >
> > Please do log a bug.
> >
> > Rgds,Rory
> > >
> > > Uwe
> > >
> > > -----
> > > Uwe Schindler
> > > H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de
> > > eMail: uwe@thetaphi.de
> > >
> > >
> > >> -----Original Message-----
> > >> From: Policeman Jenkins Server [mailto:jenkins@thetaphi.de]
> > >> Sent: Thursday, March 19, 2015 1:15 PM
> > >> To: dev@lucene.apache.org
> > >> Subject: [JENKINS] Lucene-Solr-5.x-Linux (32bit/jdk1.9.0-ea-b54) -
> > >> Build #
> > >> 11848 - Failure!
> > >>
> > >> Build: http://jenkins.thetaphi.de/job/Lucene-Solr-5.x-Linux/11848/
> > >> Java: 32bit/jdk1.9.0-ea-b54 -server -XX:+UseConcMarkSweepGC
> > >>
> > >> All tests passed
> > >>
> > >> Build Log:
> > >> [...truncated 1899 lines...]
> > >>      [javac] Compiling 461 source files to
> > >> /home/jenkins/workspace/Lucene- Solr-5.x-
> > Linux/lucene/build/analysis/common/classes/java
> > >>      [javac] /home/jenkins/workspace/Lucene-Solr-5.x-
> > >>
> Linux/lucene/analysis/common/src/java/org/apache/lucene/analysis/util
> > >> /Ch
> > >> arArrayMap.java:568: error: incompatible types: CharArrayMap<CAP#1>
> > >> cannot be converted to CharArrayMap<V>
> > >>      [javac]     return new CharArrayMap<>(map, false);
> > >>      [javac]            ^
> > >>      [javac]   where V is a type-variable:
> > >>      [javac]     V extends Object declared in method <V>copy(Map<?,?
> > extends
> > >> V>)
> > >>      [javac]   where CAP#1 is a fresh type-variable:
> > >>      [javac]     CAP#1 extends V from capture of ? extends V
> > >>      [javac] /home/jenkins/workspace/Lucene-Solr-5.x-
> > >>
> > Linux/lucene/analysis/common/src/java/org/apache/lucene/analysis/huns
> > >> p
> > >> ell/Stemmer.java:270: warning: [rawtypes] found raw type: Arc
> > >>      [javac]   final FST.Arc<IntsRef> prefixArcs[] = new FST.Arc[3];
> > >>      [javac]                                                ^
> > >>      [javac]   missing type arguments for generic class Arc<T>
> > >>      [javac]   where T is a type-variable:
> > >>      [javac]     T extends Object declared in class Arc
> > >>      [javac] /home/jenkins/workspace/Lucene-Solr-5.x-
> > >>
> > Linux/lucene/analysis/common/src/java/org/apache/lucene/analysis/huns
> > >> p
> > >> ell/Stemmer.java:274: warning: [rawtypes] found raw type: Arc
> > >>      [javac]   final FST.Arc<IntsRef> suffixArcs[] = new FST.Arc[3];
> > >>      [javac]                                                ^
> > >>      [javac]   missing type arguments for generic class Arc<T>
> > >>      [javac]   where T is a type-variable:
> > >>      [javac]     T extends Object declared in class Arc
> > >>      [javac] /home/jenkins/workspace/Lucene-Solr-5.x-
> > >>
> >
> Linux/lucene/analysis/common/src/java/org/tartarus/snowball/Among.java:
> > >> 46: warning: [rawtypes] found raw type: Class
> > >>      [javac]   private static final Class<?>[] EMPTY_PARAMS = new Class[0];
> > >>      [javac]                                                      ^
> > >>      [javac]   missing type arguments for generic class Class<T>
> > >>      [javac]   where T is a type-variable:
> > >>      [javac]     T extends Object declared in class Class
> > >>      [javac] Note: Some input files use or override a deprecated API.
> > >>      [javac] Note: Recompile with -Xlint:deprecation for details.
> > >>      [javac] 1 error
> > >>
> > >> [...truncated 1 lines...]
> > >> BUILD FAILED
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/build.xml:529: The
> > >> following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/build.xml:477: The
> > >> following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/build.xml:61: The
> > >> following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/extra-targets.xml:39:
> > >> The following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/lucene/build.xml:456:
> > >> The following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/lucene/common-
> > >> build.xml:2166: The following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-
> > >> Linux/lucene/analysis/build.xml:106: The following error occurred
> > >> while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-
> > >> Linux/lucene/analysis/build.xml:38: The following error occurred
> > >> while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/lucene/module-
> > >> build.xml:58: The following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/lucene/module-
> > >> build.xml:55: The following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/lucene/common-
> > >> build.xml:520: The following error occurred while executing this line:
> > >> /home/jenkins/workspace/Lucene-Solr-5.x-Linux/lucene/common-
> > >> build.xml:1882: Compile failed; see the compiler error output for details.
> > >>
> > >> Total time: 15 minutes 25 seconds
> > >> Build step 'Invoke Ant' marked build as failure [description-setter]
> > >> Description set: Java: 32bit/jdk1.9.0-ea-b54 -server -
> > >> XX:+UseConcMarkSweepGC Archiving artifacts Recording test results
> > >> Email was triggered for: Failure - Any Sending email for trigger:
> > >> Failure - Any
> > >>
> > >
> >
> > --
> > Rgds,Rory O'Donnell
> > Quality Engineering Manager
> > Oracle EMEA , Dublin, Ireland
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: dev-help@lucene.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org