DEV Community

Discussion on: Java is Unsound: The Industry Perspective

Collapse
 
mea5720 profile image
Michael E. Allen

As mentioned by many already, this is a great post and really helps clarify the issue both technically and practically. I actually tried the code you posted and found that Java7 (1.7.0_67) compiled the program and ran to the expected runtime exception. When I tried Java8 (1.8.0_77), however, the program failed to compile and flagged the "return bind.upcast(constrain, t);" line with this error:
The method upcast(Unsound.Constrain, B) in the type Unsound.Bind is not applicable for the arguments
(Unsound.Constrain, T)

Does that mean that Java8 is more sound, or that the compiler is broken?

Collapse
 
rosstate profile image
Ross Tate

The compiler is broken. Also note that the paper has other examples that you should try. So far we've been able to get every compiler to (correctly) compile unsound code. Even the future Java compiler!