Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » frustrating eclipse2.1.1 javac error message
frustrating eclipse2.1.1 javac error message [message #116676] Thu, 13 November 2003 19:43 Go to next message
Eclipse UserFriend
Originally posted by: ben.d.cotton.jpmorgan.com

Hi,

Is there a way to establish an eclipse2.1.1 workspace/project
configuration so that the java 1.3 compiler will *not* complain about an
inner-class reference statement (which is being mistaken for an undefined
class field reference)?
In other words, the attached program compiles fine with Sun's Java 2 SDK
1.3 "javac -d . InnerTest.java" from a command line shell, but fails with
a

"t.TheInnerClass cannot be resolved or is not a field" line 11

compiler message when run in my eclipse2.1.1 configuration.

Thanks for any help,
Ben

---------------
package com.jpmorgan.spartak.client;


public class InnerTest {
public class TheInnerClass {
public static final String f1 = "f1-value";
}

public static void main(String[] args) {
InnerTest t = new InnerTest();
System.out.println(t.TheInnerClass.f1); //can't compile in eclipse2.1.1
}
}
Re: frustrating eclipse2.1.1 javac error message [message #116684 is a reply to message #116676] Thu, 13 November 2003 21:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomann.ca.ibm.comNOSPAM

Le Thu, 13 Nov 2003 19:43:32 +0000 (UTC), ben.d.cotton@jpmorgan.com
(Ben Cotton) a écrit :
>Is there a way to establish an eclipse2.1.1 workspace/project
>configuration so that the java 1.3 compiler will *not* complain about an
>inner-class reference statement (which is being mistaken for an undefined
>class field reference)?
>In other words, the attached program compiles fine with Sun's Java 2 SDK
>1.3 "javac -d . InnerTest.java" from a command line shell, but fails with
>a
>
> "t.TheInnerClass cannot be resolved or is not a field" line 11
>
>compiler message when run in my eclipse2.1.1 configuration.
What did you try to do?

Neither javac 1.4.1 or 1.4.2 or jikes 1.18 compile your code.

javac 1.4.2:

C:\>jdk142

D:\temp>javac InnerTest.java
InnerTest.java:8: unexpected type
required: class, package
found : variable
System.out.println(t.TheInnerClass.f1); //can't compile in
eclipse2.1.1
^
1 error

javac 1.4.1:

C:\>jdk141

D:\temp>javac InnerTest.java
InnerTest.java:8: unexpected type
required: class, package
found : variable
System.out.println(t.TheInnerClass.f1); //can't compile in
eclipse2.1.1
^
1 error

Jikes 1.18:

D:\temp>jikes -classpath d:/jars/rt.jar;.;d:/temp/junit.jar
InnerTest.java

Found 1 semantic error compiling "D:/temp/InnerTest.java":

8. System.out.println(t.TheInnerClass.f1); //can't compile in
eclipse2.1.1
^-----------^
*** Semantic Error: A type "TheInnerClass" was found where a field
name or method call was expected. Did you mean to write
"TheInnerClass.xxx", or "new TheInnerClass()", or ... ?

Javac 1.3.1 compiles it, but I believe this was a bug that has been
fixed since.

So fix your code and it will compile with Eclipse compiler and javac
1.4.1 and javac 1.4.2 and jikes 1.18. I believe you simply need to
remove the 't.' in front of the TheInnerClass.f1.
--
Olivier
Re: frustrating eclipse2.1.1 javac error message [message #116692 is a reply to message #116676] Thu, 13 November 2003 21:35 Go to previous messageGo to next message
Jean-Christophe Deprez is currently offline Jean-Christophe DeprezFriend
Messages: 133
Registered: July 2009
Senior Member
i would bet that the situation where you're accessing a static member of
an inner class through both static and non-static means in the same
expression is not well-defined. anyway, is IMHO that form is *very*
ugly/improper/confusing. static members are all treated the same, no
matter where they're created, and it's always best to access static
members statically. do this instead:

System.out.println(InnerTest.TheInnerClass.f1);

this compiles fine.

hth,
alvin
Re: frustrating eclipse2.1.1 javac error message [message #116723 is a reply to message #116684] Thu, 13 November 2003 22:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.d.cotton.jpmorgan.com

Oliver,

Thanks for your very fast reply. Just now I tried the test for 1.4 and,
for me, the InnerTest.java code compiles/executes without errors nor
warnings using Sun's Java 2 SDK 1.41_03. I will try it later using Sun's
Java 2 SDK 1.42_02. It also compiles in JBuilder9, without errors nor
warnings, for both 1.3 and 1.4 compiler configurations.

Besides what I'm seeing in 1.4, however, what process is Eclipse 2.1.1
engaging in that causes the

"t.TheInnerClass cannot be resolved or is not a field" line 11

message to be generated, even when I have everything configured in

(Window->Preferences->Java->ClasspathVariables->JRE_LIB) and
(Window->Preferences->Java->InstalledJREs) to refer to my local install of
Sun's Java SDK 1.31?

You acknowledge that InnerTest.java works for your local SDK 1.3 command
line compile/execute. Even in conceding that SDK 1.3 may have a bug that
allows it to compile InnerTest.java in defiance of the language
specification, shouldn't Eclipse 2.1.1 defer to my "InstalledJRE"
configuration indication? And, thus, not produce an error message that
SDK 1.3 wouldn't produce?

Thanks, Ben




Olivier Thomann wrote:

> Le Thu, 13 Nov 2003 19:43:32 +0000 (UTC), ben.d.cotton@jpmorgan.com
> (Ben Cotton) a écrit :
> >Is there a way to establish an eclipse2.1.1 workspace/project
> >configuration so that the java 1.3 compiler will *not* complain about an
> >inner-class reference statement (which is being mistaken for an undefined
> >class field reference)?
> >In other words, the attached program compiles fine with Sun's Java 2 SDK
> >1.3 "javac -d . InnerTest.java" from a command line shell, but fails with
> >a
> >
> > "t.TheInnerClass cannot be resolved or is not a field" line 11
> >
> >compiler message when run in my eclipse2.1.1 configuration.
> What did you try to do?

> Neither javac 1.4.1 or 1.4.2 or jikes 1.18 compile your code.

> javac 1.4.2:

> C:>jdk142

> D:temp>javac InnerTest.java
> InnerTest.java:8: unexpected type
> required: class, package
> found : variable
> System.out.println(t.TheInnerClass.f1); //can't compile in
> eclipse2.1.1
> ^
> 1 error

> javac 1.4.1:

> C:>jdk141

> D:temp>javac InnerTest.java
> InnerTest.java:8: unexpected type
> required: class, package
> found : variable
> System.out.println(t.TheInnerClass.f1); //can't compile in
> eclipse2.1.1
> ^
> 1 error

> Jikes 1.18:

> D:temp>jikes -classpath d:/jars/rt.jar;.;d:/temp/junit.jar
> InnerTest.java

> Found 1 semantic error compiling "D:/temp/InnerTest.java":

> 8. System.out.println(t.TheInnerClass.f1); //can't compile in
> eclipse2.1.1
> ^-----------^
> *** Semantic Error: A type "TheInnerClass" was found where a field
> name or method call was expected. Did you mean to write
> "TheInnerClass.xxx", or "new TheInnerClass()", or ... ?

> Javac 1.3.1 compiles it, but I believe this was a bug that has been
> fixed since.

> So fix your code and it will compile with Eclipse compiler and javac
> 1.4.1 and javac 1.4.2 and jikes 1.18. I believe you simply need to
> remove the 't.' in front of the TheInnerClass.f1.
> --
> Olivier
Re: frustrating eclipse2.1.1 javac error message [message #116789 is a reply to message #116692] Thu, 13 November 2003 22:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.d.cotton.jpmorgan.com

Alvin,

Thanks, yes, that is helpful. I agree that the non-static use of the
't.TheInnerClass.f1' reference is awkward, confusing ... and extremely
uncommon (by specification, static members of inner classes can only be
constants). Nevertheless, Eclipse 2.1.1 (configured explicitly for JDK
1.3) reports this as an error when JDK 1.3 from the command-line does not.
I'm hoping to understand why Eclipse 2.1.1 behaves this way.
Tongue-in-cheek, I feel sort of a mini "Eclipse defiance" of my
Installed/Configured JRE indication. :-)

Ben

Alvin Thompson wrote:

> i would bet that the situation where you're accessing a static member of
> an inner class through both static and non-static means in the same
> expression is not well-defined. anyway, is IMHO that form is *very*
> ugly/improper/confusing. static members are all treated the same, no
> matter where they're created, and it's always best to access static
> members statically. do this instead:

> System.out.println(InnerTest.TheInnerClass.f1);

> this compiles fine.

> hth,
> alvin
Re: frustrating eclipse2.1.1 javac error message [message #116823 is a reply to message #116723] Fri, 14 November 2003 01:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manahan.NOSPAM.ca.ibm.com

Eclipse has its own compiler and doesn't use javac. So it is defering to
your InstalledJRE setting, as those are the libs it is compiling against
and against the 1.3 language spec. It just doesn't have the same bugs as
javac for 1.3 does in that space.

Peter

Ben Cotton wrote:
> Oliver,
>
> Thanks for your very fast reply. Just now I tried the test for 1.4 and,
> for me, the InnerTest.java code compiles/executes without errors nor
> warnings using Sun's Java 2 SDK 1.41_03. I will try it later using Sun's
> Java 2 SDK 1.42_02. It also compiles in JBuilder9, without errors nor
> warnings, for both 1.3 and 1.4 compiler configurations.
>
> Besides what I'm seeing in 1.4, however, what process is Eclipse 2.1.1
> engaging in that causes the
>
> "t.TheInnerClass cannot be resolved or is not a field" line 11
>
> message to be generated, even when I have everything configured in
>
> (Window->Preferences->Java->ClasspathVariables->JRE_LIB) and
> (Window->Preferences->Java->InstalledJREs) to refer to my local install of
> Sun's Java SDK 1.31?
>
> You acknowledge that InnerTest.java works for your local SDK 1.3 command
> line compile/execute. Even in conceding that SDK 1.3 may have a bug that
> allows it to compile InnerTest.java in defiance of the language
> specification, shouldn't Eclipse 2.1.1 defer to my "InstalledJRE"
> configuration indication? And, thus, not produce an error message that
> SDK 1.3 wouldn't produce?
>
> Thanks, Ben
>
>
>
>
> Olivier Thomann wrote:
>
>
>>Le Thu, 13 Nov 2003 19:43:32 +0000 (UTC), ben.d.cotton@jpmorgan.com
>>(Ben Cotton) a écrit :
>>
>>>Is there a way to establish an eclipse2.1.1 workspace/project
>>>configuration so that the java 1.3 compiler will *not* complain about an
>>>inner-class reference statement (which is being mistaken for an undefined
>>>class field reference)?
>>>In other words, the attached program compiles fine with Sun's Java 2 SDK
>>>1.3 "javac -d . InnerTest.java" from a command line shell, but fails with
>>>a
>>>
>>> "t.TheInnerClass cannot be resolved or is not a field" line 11
>>>
>>>compiler message when run in my eclipse2.1.1 configuration.
>>
>>What did you try to do?
>
>
>>Neither javac 1.4.1 or 1.4.2 or jikes 1.18 compile your code.
>
>
>>javac 1.4.2:
>
>
>>C:>jdk142
>
>
>>D:temp>javac InnerTest.java
>>InnerTest.java:8: unexpected type
>>required: class, package
>>found : variable
>> System.out.println(t.TheInnerClass.f1); //can't compile in
>>eclipse2.1.1
>> ^
>>1 error
>
>
>>javac 1.4.1:
>
>
>>C:>jdk141
>
>
>>D:temp>javac InnerTest.java
>>InnerTest.java:8: unexpected type
>>required: class, package
>>found : variable
>> System.out.println(t.TheInnerClass.f1); //can't compile in
>>eclipse2.1.1
>> ^
>>1 error
>
>
>>Jikes 1.18:
>
>
>>D:temp>jikes -classpath d:/jars/rt.jar;.;d:/temp/junit.jar
>>InnerTest.java
>
>
>>Found 1 semantic error compiling "D:/temp/InnerTest.java":
>
>
>> 8. System.out.println(t.TheInnerClass.f1); //can't compile in
>>eclipse2.1.1
>> ^-----------^
>>*** Semantic Error: A type "TheInnerClass" was found where a field
>>name or method call was expected. Did you mean to write
>>"TheInnerClass.xxx", or "new TheInnerClass()", or ... ?
>
>
>>Javac 1.3.1 compiles it, but I believe this was a bug that has been
>>fixed since.
>
>
>>So fix your code and it will compile with Eclipse compiler and javac
>>1.4.1 and javac 1.4.2 and jikes 1.18. I believe you simply need to
>>remove the 't.' in front of the TheInnerClass.f1.
>>--
>>Olivier
>
>
>
Re: frustrating eclipse2.1.1 javac error message [message #116926 is a reply to message #116823] Fri, 14 November 2003 14:34 Go to previous message
Eclipse UserFriend
Originally posted by: ben.d.cotton.jpmorgan.com

Thanks Peter (and everyone else). I downloaded Sun's Java 2 SDK 1.42_02
and, indeed, InnerTest.java failed to compile. Pre-1.42 JDKs from Sun
definitely had a bug, evidenced by their successfully compiling the
incorrect InnerTest.java. Thanks again.

Peter Manahan wrote:

> Eclipse has its own compiler and doesn't use javac. So it is defering to
> your InstalledJRE setting, as those are the libs it is compiling against
> and against the 1.3 language spec. It just doesn't have the same bugs as
> javac for 1.3 does in that space.

> Peter

> Ben Cotton wrote:
> > Oliver,
> >
> > Thanks for your very fast reply. Just now I tried the test for 1.4 and,
> > for me, the InnerTest.java code compiles/executes without errors nor
> > warnings using Sun's Java 2 SDK 1.41_03. I will try it later using Sun's
> > Java 2 SDK 1.42_02. It also compiles in JBuilder9, without errors nor
> > warnings, for both 1.3 and 1.4 compiler configurations.
> >
> > Besides what I'm seeing in 1.4, however, what process is Eclipse 2.1.1
> > engaging in that causes the
> >
> > "t.TheInnerClass cannot be resolved or is not a field" line 11
> >
> > message to be generated, even when I have everything configured in
> >
> > (Window->Preferences->Java->ClasspathVariables->JRE_LIB) and
> > (Window->Preferences->Java->InstalledJREs) to refer to my local install of
> > Sun's Java SDK 1.31?
> >
> > You acknowledge that InnerTest.java works for your local SDK 1.3 command
> > line compile/execute. Even in conceding that SDK 1.3 may have a bug that
> > allows it to compile InnerTest.java in defiance of the language
> > specification, shouldn't Eclipse 2.1.1 defer to my "InstalledJRE"
> > configuration indication? And, thus, not produce an error message that
> > SDK 1.3 wouldn't produce?
> >
> > Thanks, Ben
> >
> >
> >
> >
> > Olivier Thomann wrote:
> >
> >
> >>Le Thu, 13 Nov 2003 19:43:32 +0000 (UTC), ben.d.cotton@jpmorgan.com
> >>(Ben Cotton) a écrit :
> >>
> >>>Is there a way to establish an eclipse2.1.1 workspace/project
> >>>configuration so that the java 1.3 compiler will *not* complain about an
> >>>inner-class reference statement (which is being mistaken for an undefined
> >>>class field reference)?
> >>>In other words, the attached program compiles fine with Sun's Java 2 SDK
> >>>1.3 "javac -d . InnerTest.java" from a command line shell, but fails with
> >>>a
> >>>
> >>> "t.TheInnerClass cannot be resolved or is not a field" line 11
> >>>
> >>>compiler message when run in my eclipse2.1.1 configuration.
> >>
> >>What did you try to do?
> >
> >
> >>Neither javac 1.4.1 or 1.4.2 or jikes 1.18 compile your code.
> >
> >
> >>javac 1.4.2:
> >
> >
> >>C:>jdk142
> >
> >
> >>D:temp>javac InnerTest.java
> >>InnerTest.java:8: unexpected type
> >>required: class, package
> >>found : variable
> >> System.out.println(t.TheInnerClass.f1); //can't compile in
> >>eclipse2.1.1
> >> ^
> >>1 error
> >
> >
> >>javac 1.4.1:
> >
> >
> >>C:>jdk141
> >
> >
> >>D:temp>javac InnerTest.java
> >>InnerTest.java:8: unexpected type
> >>required: class, package
> >>found : variable
> >> System.out.println(t.TheInnerClass.f1); //can't compile in
> >>eclipse2.1.1
> >> ^
> >>1 error
> >
> >
> >>Jikes 1.18:
> >
> >
> >>D:temp>jikes -classpath d:/jars/rt.jar;.;d:/temp/junit.jar
> >>InnerTest.java
> >
> >
> >>Found 1 semantic error compiling "D:/temp/InnerTest.java":
> >
> >
> >> 8. System.out.println(t.TheInnerClass.f1); //can't compile in
> >>eclipse2.1.1
> >> ^-----------^
> >>*** Semantic Error: A type "TheInnerClass" was found where a field
> >>name or method call was expected. Did you mean to write
> >>"TheInnerClass.xxx", or "new TheInnerClass()", or ... ?
> >
> >
> >>Javac 1.3.1 compiles it, but I believe this was a bug that has been
> >>fixed since.
> >
> >
> >>So fix your code and it will compile with Eclipse compiler and javac
> >>1.4.1 and javac 1.4.2 and jikes 1.18. I believe you simply need to
> >>remove the 't.' in front of the TheInnerClass.f1.
> >>--
> >>Olivier
> >
> >
> >
Previous Topic:Code Formatter Extension points ?
Next Topic:How to define a connection in EasySQL plugin
Goto Forum:
  


Current Time: Sun Sep 01 01:00:06 GMT 2024

Powered by FUDForum. Page generated in 0.03040 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top