Bug 324850 - Compile error claims method is missing but is inherited
Summary: Compile error claims method is missing but is inherited
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-09 09:48 EDT by Darin Wright CLA
Modified: 2010-12-07 07:10 EST (History)
9 users (show)

See Also:
satyam.kandula: review+
Olivier_Thomann: review+


Attachments
Stripped-down example projects (4.05 KB, application/x-download)
2010-09-09 09:59 EDT, Markus Keller CLA
no flags Details
Regression test (2.84 KB, patch)
2010-09-09 11:39 EDT, Olivier Thomann CLA
no flags Details | Diff
ConsoleSession patch (2.05 KB, patch)
2010-09-09 14:26 EDT, Thomas Watson CLA
no flags Details | Diff
Preliminary patch under test (33.11 KB, patch)
2010-09-16 07:30 EDT, Srikanth Sankaran CLA
no flags Details | Diff
Patch under test (31.37 KB, patch)
2010-09-27 07:38 EDT, Srikanth Sankaran CLA
no flags Details | Diff
Revised patch under test (151.32 KB, patch)
2010-09-28 20:04 EDT, Srikanth Sankaran CLA
no flags Details | Diff
Revised patch - passes all JDT/Core tests (163.41 KB, patch)
2010-09-29 06:24 EDT, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Wright CLA 2010-09-09 09:48:01 EDT
In N20100908-2000, there is a compile error reported against PDE:

1. ERROR in /src/org/eclipse/pde/internal/ui/util/OSGiConsole.java
 (at line 36)
session = new ConsoleSession() {
The type new ConsoleSession(){} must implement the inherited abstract method ServiceFactory.ungetService(Bundle, ServiceRegistration, Object) 

However, looking at the code, the ungetService method is actually provided by ConsoleSession, using generics:

/**
 * @noreference This method is not intended to be referenced by clients.
 * @since 3.7
 */
public final void ungetService(Bundle bundle, ServiceRegistration<ConsoleSession> registration, ConsoleSession service) {
	// do nothing
}

ConsoleSession - the base class in org.eclipse.osgi, is compiled with 1.5 options, and the leaf class in org.eclipse.pde.ui, is compiled with 1.4 options. Adding the following method to the class in PDE makes the error go away, but I don't think the method should be needed:

public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {}
Comment 1 Olivier Thomann CLA 2010-09-09 09:50:11 EDT
This is another example of mixed 1.4 and 1.5. OSGi is compiled in 1.5, but it is used as a raw type in pde.ui.
If pde.ui is compiled in 1.5 mode, then everything compiles fine without any change.
Comment 2 Markus Keller CLA 2010-09-09 09:59:02 EDT
Created attachment 178519 [details]
Stripped-down example projects

What's interesting is that the anonymous class compiles fine when the superclass is not abstract.
Comment 3 Markus Keller CLA 2010-09-09 10:06:48 EDT
Note that unlike the previous problems, this is not only broken in the reconciler.

I guess the problem is that the anonymous ConsoleSession is missing the synthetic bridge method. Adding this to the new ConsoleSession() {..} solves the compile error:

	public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
		ungetService(bundle, registration, (ConsoleSession) service);
	}
Comment 4 Olivier Thomann CLA 2010-09-09 11:39:30 EDT
Created attachment 178526 [details]
Regression test

This disabled regression test should help to track this issue down.
Everything is fine if the client code is compiled in 1.5 mode or if the class is not abstract.
Comment 5 Olivier Thomann CLA 2010-09-09 11:42:40 EDT
I committed the regression test.
Comment 6 Thomas Watson CLA 2010-09-09 12:26:04 EDT
I am likely going to backout the changes to ConsoleSession that caused this issue in the build for now.
Comment 7 BJ Hargrave CLA 2010-09-09 12:33:14 EDT
(In reply to comment #6)
> I am likely going to backout the changes to ConsoleSession that caused this
> issue in the build for now.

Don't revert to raw. Just change the generic types to <ConsoleSession, Object> to get the desired erasure (and add some necessary casts since the tracked type is now Object).
Comment 8 Thomas Watson CLA 2010-09-09 14:26:50 EDT
Created attachment 178543 [details]
ConsoleSession patch

(In reply to comment #7)
> (In reply to comment #6)
> > I am likely going to backout the changes to ConsoleSession that caused this
> > issue in the build for now.
> 
> Don't revert to raw. Just change the generic types to <ConsoleSession, Object>
> to get the desired erasure (and add some necessary casts since the tracked type
> is now Object).

We are really just talking about ConsoleSession which implements ServiceFactory<ConsoleSession>.  I think that needs to change to ServiceFactory<Object> to work around this bug.  This should not affect the code that does the actual tracking of ConsoleSession services.
Comment 9 Thomas Watson CLA 2010-09-09 14:33:00 EDT
I released the ConsoleSession patch to allow the nightly build to succeed tonight.
Comment 10 Srikanth Sankaran CLA 2010-09-10 03:09:52 EDT
This case shows the unpreparedness of JDT/Core to
deal with this sort of mixing of projects. Or for a
1.4 having supertypes from 1.5 project.

Basically, it would appear it is a folly to drop any
generic information if present at all.

Also wherever compiler code is partitioned into two
parallel universes for pre-generics & post-generics
we are going to have trouble. For instance the current
problem comes at least partly from the compiler using 1.4
method verification code.

Under investigation.
Comment 11 Srikanth Sankaran CLA 2010-09-16 01:46:47 EDT
(In reply to comment #2)

> What's interesting is that the anonymous class compiles fine when the
> superclass is not abstract.

That is because the "method verifier", the piece of the compiler
that makes sure that a type fulfills its contractual obligations
can assume that the super class must have implemented a concrete
version of the method which the current class will automatically
inherit. Failing which it can assume that the error would have
been reported against the super class.

(In reply to comment #3)
> Note that unlike the previous problems, this is not only broken in the
> reconciler.

I have a patch that is under test that fixes the problem in the
compiler proper, though we are back to the same issue of the
schizophrenic name lookup environment as far as the reconciler is
concerned.

If the patch holds up to scrutiny and test, I would like to split
this defect and create a fresh one for the reconciler and close the
current one.
Comment 12 Srikanth Sankaran CLA 2010-09-16 07:30:14 EDT
Created attachment 179022 [details]
Preliminary patch under test
Comment 13 Srikanth Sankaran CLA 2010-09-16 08:46:13 EDT
Comment on attachment 179022 [details]
Preliminary patch under test

Fails some tests, back to investigation
Comment 14 Srikanth Sankaran CLA 2010-09-27 07:38:31 EDT
Created attachment 179624 [details]
Patch under test

This patch fixes the problem in both the reconciler and the
compiler. This is under test. Since some very basic things
are totally rewired in this patch (e.g, we now use 
MethodVerifier15 to verify the contracts implemented by even
<= 1.4 types), this patch needs to be put through torture test
before release and will likely need more massaging before it
is fully cooked. Stay tuned.
Comment 15 Srikanth Sankaran CLA 2010-09-28 20:04:02 EDT
Created attachment 179799 [details]
Revised patch under test

This patch includes adjustments to the
expected output of a bunch of JDT/Core
tests that are seeing different diagnostics
due to the admission of type variables in
scenarios where they would previously be dropped.

For the most part the new diagnostics are better
as they avoid secondary errors.
Comment 16 Srikanth Sankaran CLA 2010-09-29 06:24:06 EDT
Created attachment 179821 [details]
Revised patch - passes all JDT/Core tests

Will test some more before code review and release.
Comment 17 Srikanth Sankaran CLA 2010-09-29 11:22:58 EDT
(In reply to comment #16)
> Created an attachment (id=179821) [details]
> Revised patch - passes all JDT/Core tests
> 
> Will test some more before code review and release.

Deepak (Thanks!) confirmed that all JDT/UI tests pass too.
Comment 18 Srikanth Sankaran CLA 2010-10-01 02:03:24 EDT
Satyam, please review - TIA.
Comment 19 Srikanth Sankaran CLA 2010-10-01 02:09:26 EDT
Olivier, please also review. Since this is a major change in
some ways, I'll release after I return my vacation (18th Oct)
so I can be available to quickly work on any ripples
this results in.
Comment 20 Olivier Thomann CLA 2010-10-05 09:44:54 EDT
As far as I can say, the patch looks good.
Comment 21 Satyam Kandula CLA 2010-10-18 03:58:36 EDT
The changes look good to me.
Comment 22 Srikanth Sankaran CLA 2010-10-20 01:52:45 EDT
Released in HEAD for 3.7M3
Comment 23 Jay Arthanareeswaran CLA 2010-10-26 07:39:20 EDT
Verified for 3.7M3 using build I20101025-0901.
Comment 24 Olivier Thomann CLA 2010-10-28 10:50:13 EDT
Revert in bug 328775 comment 4.
Will be released again as soon as M3 is declared.
Comment 25 Srikanth Sankaran CLA 2010-11-01 10:33:26 EDT
(Re)Released in HEAD for 3.7 M4
Comment 26 Srikanth Sankaran CLA 2010-11-01 10:54:07 EDT
I have also released the fixes for bug 328689 bug 328775 and
bug 328827. None of these 3 bugs were directly brought about
by the fix for the current bug though they were exposed by the
fix to bug 324850 - there could be more problems lurking - we
would like to request some early testing via the upcoming I 
builds to catch these problem well in time to be addressed for M4
Comment 27 Ayushman Jain CLA 2010-12-07 07:10:27 EST
verified for 3.7M4 using build I20101205-2000.