This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Java: verification of interface types


Per Bothner wrote:

> Yes.  That's what makes verification difficult - you don't know the
> compile-time types of the variables.  Consider:
>
> interface A { }
> interface B { }
> interface C extends A, B { };
> interface D extends A, B { };
> class E implements A, B { };
> A a;
> B b;
> C c;
> if (b) c = a;
> else c = b;
>
> Consider determining the type of c at this point in the generated
> bytecode.  All we know if c can be either A or B, so it must have a
> type that is the intersection of A and B.  But it could be any of C,
> D, or E or any other class or interface that inherits from both A and
> B.  We won't know which until the value in c is further refined.

But isn't the compile-time type of "c" "C"? Isn't it enough to verify that the
bytecode doesn't try to assign "a" to "c" without a runtime checkcast? Or is this
allowed at the bytecode level? If its legal for bytecode to be non-typesafe (and I
do confess ignorance when it comes to bytecode), it seems like it would be
extremely non-trivial to prove the runtime type of "c" here. What if "c" is a
public method parameter? It could have anything assigned to it!

regards

  [ bryce ]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]