S
Stefan Ram
I have noticed a difference in report style between the
following error messages:
interface A {}
interface A_ {}
class B implements A, A_ {}
class C implements A, A_ {}
public class Main
{ static void f( final java.lang.String s ){}
public static void main( java.lang.String[] args )
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
Main.java:49: f(java.lang.String) in Main cannot be applied to (java.lang.Object&A&A_)
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
^
Here, one can notice that "java.lang.Object" is being
mentioned. If "A_" is removed, one might expect
"java.lang.Object&A" as type, but gets only "A":
interface A {}
class B implements A {}
class C implements A {}
public class Main
{ static void f( final java.lang.String s ){}
public static void main( java.lang.String[] args )
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
Main.java:45: f(java.lang.String) in Main cannot be applied to (A)
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
^
Why is "java.lang.Object" dropped now? Or, why was it
mentioned in the first case?
And why can I not declare variables of such "&"-types?
interface A {}
interface B {}
public class Main
{ static void f( final java.lang.String s ){}
public static void main( java.lang.String[] args )
{ A&B a; }}
How are these static types (in parentheses and with "&")
called, which are mentioned in error message, but can not be
used in the source code?
OK, if this was needed, I could write
interface C implements A, B {} (...) C a;
(The compiler used was from a recent mustang (1.6) build.)
following error messages:
interface A {}
interface A_ {}
class B implements A, A_ {}
class C implements A, A_ {}
public class Main
{ static void f( final java.lang.String s ){}
public static void main( java.lang.String[] args )
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
Main.java:49: f(java.lang.String) in Main cannot be applied to (java.lang.Object&A&A_)
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
^
Here, one can notice that "java.lang.Object" is being
mentioned. If "A_" is removed, one might expect
"java.lang.Object&A" as type, but gets only "A":
interface A {}
class B implements A {}
class C implements A {}
public class Main
{ static void f( final java.lang.String s ){}
public static void main( java.lang.String[] args )
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
Main.java:45: f(java.lang.String) in Main cannot be applied to (A)
{ f( Math.random() < 0.5 ? new B() : new C() ); }}
^
Why is "java.lang.Object" dropped now? Or, why was it
mentioned in the first case?
And why can I not declare variables of such "&"-types?
interface A {}
interface B {}
public class Main
{ static void f( final java.lang.String s ){}
public static void main( java.lang.String[] args )
{ A&B a; }}
How are these static types (in parentheses and with "&")
called, which are mentioned in error message, but can not be
used in the source code?
OK, if this was needed, I could write
interface C implements A, B {} (...) C a;
(The compiler used was from a recent mustang (1.6) build.)