Bug 244164 - [1.5][compiler] Missing implementation error when referencing a generic field with error
Summary: [1.5][compiler] Missing implementation error when referencing a generic field...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-14 10:09 EDT by Olivier Thomann CLA
Modified: 2009-02-09 09:40 EST (History)
4 users (show)

See Also:


Attachments
Regression test (2.02 KB, patch)
2008-08-14 12:07 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression tests (3.53 KB, patch)
2008-09-09 11:38 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression tests (4.21 KB, patch)
2008-09-09 12:49 EDT, Olivier Thomann CLA
no flags Details | Diff
Patch for 3.4 maintenance branch (4.83 KB, patch)
2009-02-09 09:40 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2008-08-14 10:09:58 EDT
Using HEAD, compiling the code reports a missing implementation error in the compiler.

import java.util.HashMap;
import java.util.Map;

public class X {
        private static Map<String, Zork> map = new HashMap<String, X>();

        public static X foo(String s) {
                return map.get(s);
        }
}

reports:
----------
1. ERROR in D:\tests_sources\X.java (at line 5)
	private static Map<String, Zork> map = new HashMap<String, X>();
	                           ^^^^
Zork cannot be resolved to a type
----------
2. ERROR in D:\tests_sources\X.java (at line 8)
	return map.get(s);
	       ^^^
Missing code implementation in the compiler
----------
2 problems (2 errors)[compiled 9 lines in 422 ms: 21.3 lines/s]

The second error should not be reported. This comes from the fact that the type of the field cannot be resolved.
Comment 1 Olivier Thomann CLA 2008-08-14 10:10:12 EDT
I'll investigate.
Comment 2 Olivier Thomann CLA 2008-08-14 12:06:06 EDT
If I change the ParameterizedTypeBinding implementation of problemId() to return ProblemReasons.NotFound in the case the inner type is a binary type binding, then some tests inside:
org.eclipse.jdt.core.tests.model.CompletionTests_1_5
org.eclipse.jdt.core.tests.model.CompletionWithMissingTypesTests_1_5
org.eclipse.jdt.core.tests.dom.ASTConverter15Test
are failing.

It is possible to pass all the tests by changing the org.eclipse.jdt.internal.compiler.problem.ProblemReporter.invalidType(ASTNode, TypeBinding) implementation to test for the tagbit TagBits.HasMissingType, but this looks more like a hack.

I'll talk with David when he is back from vacations.
Comment 3 Olivier Thomann CLA 2008-08-14 12:07:21 EDT
Created attachment 110000 [details]
Regression test
Comment 4 Olivier Thomann CLA 2008-08-14 12:09:30 EDT
Released disabled regression test org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#_test1369
Comment 5 Olivier Thomann CLA 2008-08-14 13:29:31 EDT
David,

If I report an type not found error when a parameterized type binding has a arguments that cannot be resolved, some tests fail in the completion 1.5 tests.
I believe reporting this error code is the right thing to do.

Could you please look at this and tell me if you have a different way to solve the completion issues?
Comment 6 Kent Johnson CLA 2008-08-21 12:39:33 EDT
Here is another case that may be related:


class X { 
	A<E> a; // E is undefined on purpose
	X() { a = new A<E>(); } // causes Missing code implementation...
}
class A<E> {}
Comment 7 Olivier Thomann CLA 2008-09-09 11:38:11 EDT
Created attachment 112086 [details]
Proposed fix + regression tests
Comment 8 Olivier Thomann CLA 2008-09-09 12:49:27 EDT
Created attachment 112103 [details]
Proposed fix + regression tests

Philippe, please review.
Comment 9 Olivier Thomann CLA 2008-09-11 20:38:48 EDT
Philippe, I release the code as it improves the current behavior.
We still have time to tune it if necessary.
Released for 3.5M2.
Added regression tests in org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1368
org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1369
Comment 10 Philipe Mulet CLA 2008-09-12 04:08:06 EDT
The fix looks good.
Comment 11 Philipe Mulet CLA 2008-09-12 04:17:34 EDT
Please also backport for 3.4.2 inclusion. This behavior is just exposing a hole in our support for missing types (since 3.4) and is somewhat a regression over 3.3 where the error message was more understandable:

3.3 BEHAVIOR===================================================================
Eclipse Java Compiler 0.791_R33x, 3.3.2, Copyright IBM Corp 2000, 2008. All rights reserved.
[compiled 315 lines in 454 ms: 693.8 lines/s]
----------
1. ERROR in X.java (at line 4)
        private static Map<String, Zork> map = new HashMap<String, X>();
                                   ^^^^
Zork cannot be resolved to a type
----------
2. ERROR in X.java (at line 6)
        return map.get(s);
               ^^^
map cannot be resolved
----------
2 problems (2 errors)

3.4 BEHAVIOR===================================================================
Eclipse Java Compiler 0.874, 3.4.0, Copyright IBM Corp 2000, 2008. All rights reserved.
[compiled 315 lines in 422 ms: 746.4 lines/s]
----------
1. ERROR in X.java (at line 4)
        private static Map<String, Zork> map = new HashMap<String, X>();
                                   ^^^^
Zork cannot be resolved to a type
----------
2. ERROR in X.java (at line 6)
        return map.get(s);
               ^^^
Missing code implementation in the compiler
----------
2 problems (2 errors)
Comment 12 Frederic Fusier CLA 2008-12-09 06:50:20 EST
Verified for 3.5M2 using build I20080918-0100.
Comment 13 Frederic Fusier CLA 2009-02-03 16:43:32 EST
Unfortunately, it seems that we missed to backport this fix to 3.4.2 stream.
So, move the target to 3.5M2 and set it as verified for this stream...
Comment 14 Philipe Mulet CLA 2009-02-04 05:16:49 EST
Too bad !
Too late for inclusion in 3.4.2. Technically, it is not super critical as it results in wrong error message being surfaced. 
The poor error message looks scary, but still localized.

Olivier - could you still prepare a 3.4.x patch for releasing to the branch post 3.4.2 (in case someone needs it).
Comment 15 Olivier Thomann CLA 2009-02-09 09:40:30 EST
Created attachment 125135 [details]
Patch for 3.4 maintenance branch

Philippe, +1 to release it in 3.4 maintenance stream ?