[non-308] Scoping problem with Resolve and javac 6 vs. 7 vs. Eclipse

Werner Dietl wdietl at gmail.com
Thu Jan 17 02:16:07 PST 2013


Since pulling in the latest jdk8/tl changesets, I'm having a build
problem in Eclipse in javac.comp.Resolve line 760.
The command-line build succeeds, which made me curious.

I reduced the issue to the attached file.

With a javac 1.6.0_24 compiler I get:

ScopingBug.java:18: cannot find symbol
symbol: method foo(java.lang.String,int)

With javac 1.7.0_09 this compiles and runs. The test could be
minimized some more to only illustrate the scoping problem; I expanded
it to make it executable and the compiled program runs correctly.

The Eclipse 3.7.2 compiler in 1.7 compliance level raises an "not
applicable" error for the call of foo.

Is this a known issue for javac 6 and Eclipse? Or is javac 7 wrong?

The work-around is easy: don't do the ugly overloading. Could we apply
such a workaround in Resolve to make my Eclipse-build happy?

To make the example even more interesting, change line 15 to:

        Itf i = new Itf() {

that is, instead of using the class Clazz use the interface Itf.
I would have assumed that this doesn't make a difference. However, now
javac 7 fails with the same error as Eclipse:

ScopingBug.java:18: error: method foo in class <anonymous Itf> cannot
be applied to given types;
                foo(s, 5);
                ^
  required: String
  found: String,int
  reason: actual and formal argument lists differ in length

Is this behavior intended?

Thanks,
cu, WMD.

-- 
http://www.google.com/profiles/wdietl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScopingBug.java
Type: application/octet-stream
Size: 563 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130117/c1155922/ScopingBug.java 


More information about the type-annotations-dev mailing list