|
Scala example source code file (bug2318.scala)
The Scala bug2318.scala source code
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()
}
}
Other Scala examples (source code examples)Here is a short list of links related to this Scala bug2318.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.