Bug 76405 - javac accepts this code while Eclipse does not
Summary: javac accepts this code while Eclipse does not
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-15 18:39 EDT by d CLA
Modified: 2004-10-27 06:34 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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