blob: cb524471d6650ea94843eb1395a45aed9ab04483 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import java.security._
object Test {
trait Bar { def bar: Unit }
object Mgr extends SecurityManager {
override def checkPermission(perm: Permission) = perm match {
case _: java.lang.RuntimePermission => ()
case _: java.io.FilePermission => ()
case x: java.security.AccessControlException if x.getName contains ".networkaddress." => () // generality ftw
case _ => super.checkPermission(perm)
}
}
def bug1() = {
val p = Runtime.getRuntime().exec("ls");
type Destroyable = { def destroy() : Unit }
def doDestroy( obj : Destroyable ) : Unit = obj.destroy();
doDestroy( p );
}
def bug2() = {
System.setSecurityManager(Mgr)
val b = new Bar { def bar = println("bar") }
b.bar
val structural = b.asInstanceOf[{ def bar: Unit }]
structural.bar
}
def main(args: Array[String]) {
// figuring this will otherwise break on windows
try bug1()
catch { case _: java.io.IOException => () }
bug2()
}
}
|