Questionable compilation failure
Millies, Sebastian
Sebastian.Millies at softwareag.com
Wed Sep 18 09:18:28 PDT 2013
Hello there,
on my Windows 7 (64bit) box, the following does not compile with the developer preview build (b 106). Should it?
import java.util.function.Supplier;
public class SupplierTest {
class Concrete<T> implements Supplier<Concrete<T>> {
@Override
public Concrete<T> get() {
return this;
}
}
interface Test {
default void doSomething() {
new Concrete<String>(); // <-----
}
}
}
The error message is:
\SupplierTest.java:16: error: non-static variable this cannot be referenced from a static context
new Concrete<String>();
^
However, a default method implementation is not static, or is it? (Perhaps it's just the error
message that's confusing me.)
n Sebastian
Software AG - Sitz/Registered office: Uhlandstra?e 12, 64297 Darmstadt, Germany - Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com
More information about the lambda-dev
mailing list