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


Bryce McKinlay <bryce@albatross.co.nz> writes:

> But isn't the compile-time type of "c" "C"?

Yes, but that information is not in the bytecode, unless the .class
files contains debugging information.

> Isn't it enough to verify that the
> bytecode doesn't try to assign "a" to "c" without a runtime checkcast?

I got my example backwards, since as you said the example would need
run-time check-casts.  Try this:

interface A { }
interface B { }
interface C extends A, B { };
interface D extends A, B { };
A a;
C c;
D d;
if (p) a = c;
else a = d;

None of these statements require run-time coercions.  The verifier
does not know the type of a.  All it knows is that a must have a type
that is a super-type of both C and D.  But that could be A or B.
So my memory was wrong: we need union types, not intersection types.
(These are union types that actually can hold only a single type -
but the verifier doesn't know which, at least not yet.)
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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