Bug 335479 - [1.5][compiler] Inconsistency with Javac
Summary: [1.5][compiler] Inconsistency with Javac
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-26 12:51 EST by Jeff McAffer CLA
Modified: 2011-03-07 09:22 EST (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 Jeff McAffer CLA 2011-01-26 12:51:06 EST
The class listed below compiles fine with javac but gives an error in the workspace and with ecj.  The error is 
    "Cannot create a generic array of Inner"

As far as I can tell, there are no compiler settings that would affect this case.

Also included below are the decompiled versions of the .class files created using javac.

package test;

public class Outer<C extends Object> {
	void foo() {
		class Inner {
			public int a; 
			public int b; 
		}
		Inner[] value = new Inner[3];
	}
}


// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 1/26/2011 11:21:22 AM
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name:   Outer.java
 
package test;
 
 
public class Outer
{
 
    public Outer()
    {
    }
 
    void foo()
    {
    /* block-local class not found */
    class _cls1Inner {}
 
        _cls1Inner value[] = new _cls1Inner[3];
    }
}
 
 
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 1/26/2011 11:22:27 AM
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name:   Outer.java
 
package test;
 
 
// Referenced classes of package com.lgc.color:
//            Outer
 
class Outer$1Inner
{
 
    public int a;
    public int b;
    final Outer this$0;
 
    Outer$1Inner()
    {
        this$0 = Outer.this;
        super();
    }
}
Comment 1 Olivier Thomann CLA 2011-01-26 13:03:26 EST
Reproduced. Looks like a bug when we check the type of the array type.
Investigating.
Comment 2 Olivier Thomann CLA 2011-01-26 13:27:39 EST
It would work for a static method. It looks like the enclosing type has to be reifiable and this is not the case here. This was changed to fix bug 130543.

javac 1.6 (1.6_24) compile that code fine. javac 1.7 (b126) reports an error and javac 1.5 (1.5_22) reports an error.

In this case the enclosing type is not reifiable, so it would make sense to report an error.
Looking at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6318240, it seems that this would be a bug in javac 1.6.

Srikanth, I let you take a look at this and decide if this needs any action.
Comment 3 Srikanth Sankaran CLA 2011-02-07 05:27:36 EST
(In reply to comment #2)
> It would work for a static method. It looks like the enclosing type has to be
> reifiable and this is not the case here. This was changed to fix bug 130543.
> 
> javac 1.6 (1.6_24) compile that code fine. javac 1.7 (b126) reports an error
> and javac 1.5 (1.5_22) reports an error.
> 
> In this case the enclosing type is not reifiable, so it would make sense to
> report an error.
> Looking at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6318240, it seems
> that this would be a bug in javac 1.6.
> 
> Srikanth, I let you take a look at this and decide if this needs any action.

Agree with the assessment. No action is called for. Resolving as INVALID.
Comment 4 Jay Arthanareeswaran CLA 2011-03-07 09:22:44 EST
Verified for 3.7M6.