Bug 105531 - [1.5][compiler] ecj from CVS generates spurious incomprehensible error
Summary: [1.5][compiler] ecj from CVS generates spurious incomprehensible error
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 blocker (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 101831 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-28 18:01 EDT by Andrew John Hughes CLA
Modified: 2005-09-26 12:00 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew John Hughes CLA 2005-07-28 18:01:42 EDT
I have been compiled the generics branch of GNU Classpath with ecj for a while,
successfully.  However, after updating to the latest CVS version this week (most
recently, yesterday's (27/7/2005)), I get a strange error which makes the build
fail:

1445. ERROR in ../java/lang/ref/ReferenceQueue.java
 (at line 91)
        ref.nextOnQueue = first == null ? ref : first;
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type mismatch: cannot convert from Reference<capture-of ? extends T> to
Reference<capture-of ? extends T>

(This is the only error; there are plenty of warnings at present due to the use
of raw collections).

To me, the error doesn't even make sense, as the two are identical.  Finding a
machine with a copy of Sun's proprietary javac for 1.5 results in a successful
compile, as did previous versions of ecj.

FWIW, ref is of type Reference<? extends T> and its nextOnQueue field is of type
Reference<T>.  first is of type Reference (although I still get the error with
Reference<T>).  I've tried casts and a variety of other things to make this
work, but to no avail.  As I say, this code hasn't changed and it does compile
with earlier versions and Sun's javac.  If there is a problem, the error message
could at least be more understandable.

Thanks.
Comment 1 Philipe Mulet CLA 2005-07-28 18:15:44 EDT
Could you provide exact steps to reproduce ?
Comment 2 Andrew John Hughes CLA 2005-07-28 19:06:17 EDT
Yes, run a build of ecj from CVS over the generics branch of GNU Classpath:

export CVS_RSH="ssh"

cvs -z3 -d:ext:anoncvs@savannah.gnu.org:/cvsroot/classpath co -r generics-branch
classpath

./autogen.sh && ./configure && make.
Comment 3 Philipe Mulet CLA 2005-07-31 17:15:30 EDT
Cannot connect:

Could not connect to :ext:anoncvs@savannah.gnu.org:/cvsroot/classpath: I/O
exception occurred: CreateProcess: ssh savannah.gnu.org -l anoncvs cvs server
error=2
Comment 4 Andrew John Hughes CLA 2005-08-01 18:03:13 EDT
Hmmm... I don't see that here, it still checks out fine.  The relevant files are
here:

http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/lang/ref/?only_with_tag=generics-branch

Note the 'generics-branch' tag.
Comment 5 Olivier Thomann CLA 2005-08-05 10:14:24 EDT
compiler v_568 had the same problem.
Comment 6 Philipe Mulet CLA 2005-08-11 08:54:22 EDT
Reproduced. Simpler testcase:

public class X<T> {
	Y first;

	void foo(Y<? extends T> ref) {
		ref.next = first == null ? ref : first;
	}
}

class Y<E> {
	Y<E> next;
}
Comment 7 Philipe Mulet CLA 2005-08-11 09:22:27 EDT
Problem comes from the fact the conditional expression is checking types in old
1.4 fashion (operand compatibility) before attempting 1.5 (LUB), which is wrong. 
Added GenericTypeTest#test799.

Fixed in both 3.1.1 and 3.2 streams.
Comment 8 Philipe Mulet CLA 2005-08-11 09:43:46 EDT
Until you get the fix, you may workaround the issue by inserting an extra cast:

        ref.nextOnQueue = first == null ? (Reference) ref : first;
Comment 9 Andrew John Hughes CLA 2005-08-11 10:35:17 EDT
The patch (using latest ecj CVS) solves that error, but spawns lots of:

22. ERROR in
../external/w3c_dom/org/w3c/dom/bootstrap/DOMImplementationRegistry.java
 (at line 318)
        return isJRE11()
            ? null
            : (ClassLoader)
              AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        ClassLoader classLoader = null;
                        try {
                            classLoader =
                                Thread.currentThread().getContextClassLoader();
                        } catch (SecurityException ex) {
                        }
                        return classLoader;
                    }
                });
              
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Incompatible conditional operand types null and ClassLoader

There are lots of those now, presumably because of the ordering change.
Comment 10 Philipe Mulet CLA 2005-08-12 04:50:33 EDT
Yes, I figured this regression as well. Got addressed in latest.
Comment 11 Philipe Mulet CLA 2005-08-12 08:48:15 EDT
*** Bug 101831 has been marked as a duplicate of this bug. ***
Comment 12 David Audel CLA 2005-09-21 10:14:40 EDT
Verified in I20050920-0010 for 3.2M2
Comment 13 David Audel CLA 2005-09-26 12:00:35 EDT
Verified using M20050923-1430 for 3.1.1