diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-02-14 00:18:54 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-02-14 00:34:48 -0500 |
commit | 465b9bfc84c21c0a599362624fa46febfa5e09c8 (patch) | |
tree | 1e7454417fe13cff7ebf425ca3beac709b341c86 /stage1 | |
parent | 349e4b3546973a30f2823fa5461767322a606d9a (diff) | |
download | cbt-465b9bfc84c21c0a599362624fa46febfa5e09c8.tar.gz cbt-465b9bfc84c21c0a599362624fa46febfa5e09c8.tar.bz2 cbt-465b9bfc84c21c0a599362624fa46febfa5e09c8.zip |
ignore classes in randomly nested subdirectories
useful for `dotty run <file>`
Diffstat (limited to 'stage1')
-rw-r--r-- | stage1/Stage1Lib.scala | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index 67c1f4e..d44f30b 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -156,14 +156,19 @@ class Stage1Lib( logger: Logger ) extends BaseLib{ .collect{ // no $ to avoid inner classes case path if !path.contains("$") && path.endsWith(".class") => - classLoader.loadClass( - path - .stripSuffix(".class") - .stripPrefix(targetDirectory.getPath) - .stripPrefix(File.separator) // 1 for the slash - .replace(File.separator, ".") - ) - }.filter( + try{ + classLoader.loadClass( + path + .stripSuffix(".class") + .stripPrefix(targetDirectory.getPath) + .stripPrefix(File.separator) // 1 for the slash + .replace(File.separator, ".") + ) + } catch { + case e: ClassNotFoundException => null + case e: NoClassDefFoundError => null + } + }.filterNot(_ == null).filter( _.getDeclaredMethods().exists( m => m.getName == "main" && m.getParameterTypes.toList == List(arrayClass) |