Bug 8040 - java source with $ in reference won't compile
Summary: java source with $ in reference won't compile
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-22 15:41 EST by OTI Support CLA
Modified: 2002-02-12 06:18 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description OTI Support CLA 2002-01-22 15:41:11 EST
Here is the testcase scenario.

package test;
 public class TestInnerClass {
    public static void setReferenceClass(Class c) {
       System.out.println(c.getName());
   }
 public static void main(String s[]) {
TestInnerClass.setReferenceClass(com.gresham.rtn.businessif.AccountBalanceIF$Acc
ountBalanceCID.class);
  }
}

//////////AccountBalanceIF.java //////////
package com.gresham.rtn.businessif;
public interface AccountBalanceIF
 {
    public class AccountBalanceCID {
    }
 }

On the base workbench, this code can not complile and we receive the error:

"The type com.gresham.rtn.businessif.AccountBalanceIF$AccountBalanceCID is an 
incorrectly specified nested type;  replace the '$' with '.'"

Notice that the same problem does not occur with VAJ 4.0, and JDK 1.3.

The problem can be get around by replacing "$" with ".". 
But the user would like the problem to be fixed.

Is this a valid error or is it working as designed?
Comment 1 Philipe Mulet CLA 2002-01-23 07:34:10 EST
If compiling against sources for AccountBalanceIF, then all compilers (at least 
since 1.2.2 and above would complain), where VAJ never got the check right I 
think.

When compiling against binaries, then JDK 1.2.2 did complain, and not since 
1.3.0 (likely because they switched their compiler implementation to new javac).

Eclipse is complaining, i.e. your source should compile in the same way against 
other code, no matter if it is in source or binary form. The innerclass spec 
used to forbide bytecode-level name for innerclasses to be specified in source.

No change is planned. User code should be converted.

Comment 2 OTI Support CLA 2002-01-23 11:07:00 EST
I think you might be incorrect regarding what javac complains about:

C:\tmp\com\gresham\rtn\businessif>d:\jdk131\bin\javac AccountBalanceIF.java

C:\tmp\com\gresham\rtn\businessif>cd \tmp\test

C:\tmp\test>d:\jdk131\bin\javac -classpath .. TestInnerClass.java

C:\tmp\test>c:\jdk122\bin\javac -classpath .. TestInnerClass.java

No warnings or errors are generated using either javac compiler.
Comment 3 Philipe Mulet CLA 2002-01-23 11:56:56 EST
Please re-read my previous comments, there is a difference when compiling 
against sources or against binaries. 

Try to compile both classes at the same time and you'll see a difference.
Comment 4 OTI Support CLA 2002-01-23 12:18:23 EST
C:\tmp\test>del *.class
C:\tmp\com\gresham\rtn\businessif>del *.class

C:\tmp>c:\jdk122\bin\javac 
C:\tmp\com\gresham\rtn\businessif\AccountBalanceIF.java c:\tmp\test\Test
InnerClass.java

C:\tmp\test>del *.class
C:\tmp\com\gresham\rtn\businessif>del *.class

C:\tmp>d:\jdk131\bin\javac 
C:\tmp\com\gresham\rtn\businessif\AccountBalanceIF.java c:\tmp\test\Test
InnerClass.java

Again, there don't seem to be any errors or warnings from javac.
Comment 5 Philipe Mulet CLA 2002-02-07 09:56:13 EST
This is a bug in javac. I see why we didn't see the same thing. Try with non 
qualified references, and it will start complaining.

package p1;
class T {
       class Member {}
}

public class X {
        p1.T$Member field1; // no complaint
        T$Member field2; // complains
        T.Member field3; // no complaint
}

We will not follow them.
Ok to close ?
Comment 6 OTI Support CLA 2002-02-07 11:07:26 EST
I think this can be closed as long as you can point us at somewhere in the Java 
spec where it shows that the bug is in javac. Unfortunately, unless there's 
documentation somewhere, people tend to treat javac as the reference 
implementation.
Comment 7 Philipe Mulet CLA 2002-02-07 18:33:01 EST
http://java.sun.com/products//jdk/1.1/docs/guide/innerclasses/spec/innerclasses.
doc2.html

"Likewise, bytecode-level class names like MyOuterClass$19 cannot be used by 
source code (except under pre-1.1 compilers, which know nothing of inner 
classes). "
Comment 8 Philipe Mulet CLA 2002-02-11 06:51:35 EST
Closing, this is a Javac bug