请选择 进入手机版 | 继续访问电脑版

技术控

    今日:307| 主题:57436
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Java and Scala's Type Systems are Unsound

[复制链接]
Deleter回忆 发表于 2016-11-27 15:16:50
155 3
The Unsound Playground

  

Java and Scala's Type Systems are Unsound

Java and Scala's Type Systems are Unsound-1-技术控-scala,type,关键字,scala,type,scala,typetag,scala,type,class
     

Java and Scala's Type Systems are Unsound

Java and Scala's Type Systems are Unsound-2-技术控-scala,type,关键字,scala,type,scala,typetag,scala,type,class
       OOPSLA '16
    Distinguished
    Artifact Award
        We, Nada Amin and Ross Tate , broke the Java and Scala type systems!Try it out for yourself by running the examples, which throw cast exceptions even though they contain no casts ↓Read our paper Java and Scala's Type Systems are Unsound to learn how these examples work →Come up with your own examples and use the save icon to update the URL to a permalink to your code ↱
    Which language would you like to break?
   Java /Scala
  
       
  • Unsound.java in Java 8(the first program we broke Java with, derived fromlegacy.scala)   
  • Unsound.java in Java 9(sometimes compilers incorrectly reject valid code)   
  • Unsound9.java in Java 9(we even broke Java in the future)   
  • UnsoundSpec.java in Java 6(incorrectly rejected unsound program that has been valid since Java 5 in 2004)   
  • Nullless.java in Java 8(this program has no occurence of null )   
  • SingleParameters.java in Java 8(every class and method in this program has exactly one parameter)  
  class Unsound { static class Constrain<A, B extends A> {} static class Bind<A> { <B extends A> A upcast(Constrain<A,B> constrain, B b) { return b; } } static <T,U> U coerce(T t) { Constrain<U,? super T> constrain = null; Bind<U> bind = new Bind<U>(); return bind.upcast(constrain, t); } public static void main(String[] args) { String zero = Unsound.<Integer,String>coerce(0); } }
  #!/bin/bash set -e -v ### PICK VERSION export JAVA_HOME=/usr/lib/jvm/java-8-oracle export PATH=$JAVA_HOME/bin:$PATH ### CHECK VERSION java -version ### COMPILE cat $1 >Unsound.java javac Unsound.java ### RUN java Unsound



上一篇:谈谈协程
下一篇:图解 Session(会话)
19760811 发表于 2016-11-27 20:54:11
好贴,被吓尿了
回复 支持 反对

使用道具 举报

尔琴 发表于 2016-11-27 22:07:43
撸过...
回复 支持 反对

使用道具 举报

vkvln 发表于 2016-11-28 18:48:34
如果每个女朋友用一个字来代替的话,我的情史可以写一部长篇小说了。
回复 支持 反对

使用道具 举报

我要投稿

回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 | 粤公网安备 44010402000842号 )

© 2001-2017 Comsenz Inc.

返回顶部 返回列表