lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <>
Subject [jira] Commented: (LUCENE-1935) Generify PriorityQueue
Date Thu, 01 Oct 2009 23:02:23 GMT


Uwe Schindler commented on LUCENE-1935:

By the way, the covariant overload is optimized away by the compiler (not the JVM), if an
anonymous or private (and therefore final) class is used. This is the code from the test:

private static class IntegerQueue extends PriorityQueue<Integer> {
    public IntegerQueue(int count) {

    protected boolean lessThan(Integer a, Integer b) {
        return (a < b);

Is compiled to the following code by Java 1.5 javac:

private static class TestPriorityQueue$IntegerQueue extends PriorityQueue {

    protected boolean lessThan(Object a, Object b) {
        return ((Integer)a).intValue() < ((Integer)b).intValue();

    public TestPriorityQueue$IntegerQueue(int count) {

So normal usage in Lucene would have no impact (would be the same as before). Only if you
override a generified PQ with a lessThan method not final or somehow accessible, the compiler
has to add the wrapper.

> Generify PriorityQueue
> ----------------------
>                 Key: LUCENE-1935
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>         Attachments: LUCENE-1935.patch
> Priority Queue should use generics like all other Java 5 Collection API classes. This
very simple, but makes code more readable.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message