Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Re: [eclipse-dev] Eclipse - JDT parsing error?

Actually, this is covered by JLS2.0. A variable name is not a valid prefix
for a type name part of a qualified type name.

======
6.5.5.2 Qualified Type Names
If a type name is of the form Q.Id, then Q must be either a type name or a
package name. If Id names exactly one type that is a member of the type or
package denoted by Q, then the qualified type name denotes that type. If Id
does not name a member type (§8.5, §9.5) within Q, or the member type named
Id within Q is not accessible (§6.6), or Id names more than one member type
within Q, then a compile-time error occurs.


The example:
      package wnj.test;
      class Test {
                   public static void main(String[] args) {
                               java.util.Date date =
                                           new
      java.util.Date(System.currentTimeMillis());
                               System.out.println(date.toLocaleString());
                   }
      }



produced the following output the first time it was run:


      Sun Jan 21 22:56:29 1996



In this example the name java.util.Date must denote a type, so we first use
the procedure recursively to determine if java.util is an accessible type
or a package, which it is, and then look to see if the type Date is
accessible in this package.





                                                                                                                                  
                      Olivier_Thomann@ot                                                                                          
                      i.com                      To:      eclipse-dev@xxxxxxxxxxx                                                 
                      Sent by:                   cc:      contact@xxxxxxxxxx                                                      
                      eclipse-dev-admin@         Subject: Re: [eclipse-dev] Eclipse - JDT parsing error?                          
                      eclipse.org                                                                                                 
                                                                                                                                  
                                                                                                                                  
                      06/05/2002 10:12                                                                                            
                      PM                                                                                                          
                      Please respond to                                                                                           
                      eclipse-dev                                                                                                 
                                                                                                                                  
                                                                                                                                  




Hi Ruslan,

In fact it fails on JDK1.4 and Jikes 1.15.

FirstClass.java:11: unexpected type
required: class, package
found   : variable
                System.out.println("CONST: " +
one.InnerClass.INNER_CONSTANT);
                                               ^
1 error

It compiles fine on JDK1.3.1. I will double check if this is not a javac
bug.
In the future send your message to the eclipse newsgroup or directly open a
bug report on bugzilla.

Olivier




                      "Ruslan

                      Gainutdinov"               To:
<eclipse-dev@xxxxxxxxxxx>

                      <subscription@rusl         cc:      "Ruslan"
<contact@xxxxxxxxxx>
                      an.org>                    Subject: [eclipse-dev]
Eclipse - JDT parsing error?
                      Sent by:

                      eclipse-dev-admin@

                      eclipse.org



                      05/06/2002 03:39

                      PM

                      Please respond to

                      eclipse-dev






Hello!

    First I would like to thank everyone for good work. Eclise is a really
good IDE and refactoring tools is very helpfull. In fact, my colleagues at
work using JBuilder and they were impressed by Eclipse abilities.

    I think I have found a bug in JDT - java code parsing(compiling?). Here
is the example class:

=========== FirstClass.java =======

public class FirstClass {

 public static final class InnerClass {
  public static final int INNER_CONSTANT = 0;
 }

 public static void main(String[] args) {
  FirstClass one = new FirstClass();
  /* The line below produces error message:
    one.InnerClass cannot be resolved or is not a field FirstClass.java */
  System.out.println("CONST: " + one.InnerClass.INNER_CONSTANT);
 }
}



_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/eclipse-dev






Back to the top