-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b14
-
x86_64
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8045163 | 8u25 | Jan Lahoda | P3 | Resolved | Fixed | b01 |
JDK-8042823 | 8u20 | Jan Lahoda | P3 | Resolved | Fixed | b15 |
JDK-8052602 | emb-8u26 | Jan Lahoda | P3 | Resolved | Fixed | b17 |
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux sandy 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compilation of the attached source causes the attached error, but moving the SourceWrapper interface lower in the file (as indicated by the comment) causes the compilation to succeed. I'm not at all sure whether the error should even be happening in the first place, since it was compiling fine in JDK7.
REGRESSION. Last worked in version 7u25
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1~deb7u1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No errors expected.
ACTUAL -
$ javac ./scratch/Main.java
./scratch/Main.java:41: error: reference to with is ambiguous
channel.with(s);
^
both method with(AccessStrategy) in SinkWrapper and method with(AccessStrategy) in SourceWrapper match
1 error
ERROR MESSAGES/STACK TRACES THAT OCCUR :
./scratch/Main.java:41: error: reference to with is ambiguous
channel.with(s);
^
both method with(AccessStrategy) in SinkWrapper and method with(AccessStrategy) in SourceWrapper match
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package scratch;
public class Main {
public interface SinkStrategy { }
public interface AccessStrategy extends SinkStrategy { }
public interface Strategy extends AccessStrategy { }
public interface Source extends SourceWrapper { }
public interface SourceWrapper {
Source with(AccessStrategy strategy);
}
public interface SinkWrapper {
Sink with(SinkStrategy strategy);
Sink with(AccessStrategy strategy);
}
// --> moving SourceWrapper to here causes compilation to succeed
public interface Sink extends Source, SinkWrapper { }
public static class Channel implements Sink {
@Override
public Sink with(AccessStrategy strategy) {
System.out.println("access " + strategy);
return null;
}
@Override
public Sink with(SinkStrategy strategy) {
System.out.println("sink " + strategy);
return null;
}
}
public static void main(String[] args) {
final Sink channel = new Channel();
final Strategy s = new Strategy() { };
channel.with(s);
}
}
---------- END SOURCE ----------
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux sandy 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compilation of the attached source causes the attached error, but moving the SourceWrapper interface lower in the file (as indicated by the comment) causes the compilation to succeed. I'm not at all sure whether the error should even be happening in the first place, since it was compiling fine in JDK7.
REGRESSION. Last worked in version 7u25
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1~deb7u1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No errors expected.
ACTUAL -
$ javac ./scratch/Main.java
./scratch/Main.java:41: error: reference to with is ambiguous
channel.with(s);
^
both method with(AccessStrategy) in SinkWrapper and method with(AccessStrategy) in SourceWrapper match
1 error
ERROR MESSAGES/STACK TRACES THAT OCCUR :
./scratch/Main.java:41: error: reference to with is ambiguous
channel.with(s);
^
both method with(AccessStrategy) in SinkWrapper and method with(AccessStrategy) in SourceWrapper match
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package scratch;
public class Main {
public interface SinkStrategy { }
public interface AccessStrategy extends SinkStrategy { }
public interface Strategy extends AccessStrategy { }
public interface Source extends SourceWrapper { }
public interface SourceWrapper {
Source with(AccessStrategy strategy);
}
public interface SinkWrapper {
Sink with(SinkStrategy strategy);
Sink with(AccessStrategy strategy);
}
// --> moving SourceWrapper to here causes compilation to succeed
public interface Sink extends Source, SinkWrapper { }
public static class Channel implements Sink {
@Override
public Sink with(AccessStrategy strategy) {
System.out.println("access " + strategy);
return null;
}
@Override
public Sink with(SinkStrategy strategy) {
System.out.println("sink " + strategy);
return null;
}
}
public static void main(String[] args) {
final Sink channel = new Channel();
final Strategy s = new Strategy() { };
channel.with(s);
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8042823 Sensitive dependence on location of nested interface
- Resolved
-
JDK-8045163 Sensitive dependence on location of nested interface
- Resolved
-
JDK-8052602 Sensitive dependence on location of nested interface
- Resolved
- relates to
-
JDK-8005179 Cleanup Resolve.AmbiguityError
- Closed