Bug 76405

Summary: javac accepts this code while Eclipse does not
Product: [Eclipse Project] JDT Reporter: d <dsmall>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: orbeon-development
Version: 3.0.1   
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description d CLA 2004-10-15 18:39:40 EDT
// Code below compiles with javac 1.3, 1.4, and 1.5.  Doesn't not
// compile with Eclipse.  Eclipse says 
// No enclosing instance of the type C1 is accessible in scope	
package p1;

public class C1 
{
    class Foo extends java.util.HashMap
	{
    	Foo()
		{
    		super( new java.util.HashMap() 
			{
    			public String toString()
    			{
    				return C1.this.toString();
    			}
			});
		}
	}
    public String toString()
    {
    	return "C1";
    }
}
Comment 1 Olivier Thomann CLA 2004-10-16 14:30:04 EDT
Note that jikes is also reporting a problem.
Found 1 semantic error compiling "C:/tests_sources/C1.java":

    12.                                 return C1.this.toString();
                                               ^-----^
*** Semantic Error: An instance of "C1.this" exists, but is not accessible at
this location because an intermediate anonymous type occurs in an explicit
constructor call.
Comment 2 d CLA 2004-10-23 18:14:24 EDT
After reviewing JLS it seems Eclipse compiler is behaving correctly.

See section 8.8.5.1 Explicit Constructor Invocations :

http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#229267

Comment 3 Frederic Fusier CLA 2004-10-27 06:34:25 EDT
Set bug to "invalid" as compiler behaves accordingly to the spec