Skip to content

Commit ebdda1c

Browse files
committed
Local working core
1 parent 98d702d commit ebdda1c

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

src/main/scala/org/scalaexercises/exercises/Exercises.scala

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,37 @@
1919

2020
package org.scalaexercises.runtime
2121

22-
import org.scalaexercises.runtime.model._
23-
2422
import scala.collection.immutable.List
2523
import scala.reflect.ClassTag
2624
import java.net.URLClassLoader
2725
import java.io.File
2826

2927
import cats.implicits._
3028
import org.clapper.classutil.ClassFinder
31-
import org.scalaexercises.evaluator.Dependency
29+
import org.objectweb.asm.Opcodes
30+
import org.scalaexercises.evaluator.types.Dependency
31+
import org.scalaexercises.runtime.model._
32+
33+
import scala.util.{Failure, Success, Try}
3234

3335
object Exercises {
3436
val LIBRARIES_PACKAGE = "org.scalaexercises.content"
3537

3638
private[this] def classMap(cl: ClassLoader) = {
37-
val files = cl.asInstanceOf[URLClassLoader].getURLs map (_.getFile)
38-
val classFinder = ClassFinder(files map (new File(_)) filter (f f.exists()))
39-
val classes = classFinder.getClasses.toIterator
40-
ClassFinder.classInfoMap(classes)
39+
val files = cl
40+
.asInstanceOf[URLClassLoader]
41+
.getURLs
42+
.map(url => new File(url.getFile)) filter (f f.exists())
43+
val classFinder = ClassFinder(files, Some(Opcodes.ASM7))
44+
val classes = classFinder.getClasses
45+
.filter(ci =>
46+
Try(ci.name
47+
.startsWith(LIBRARIES_PACKAGE) || ci.name == "org.scalaexercises.runtime.model.Library") match {
48+
case Success(value) => value
49+
case Failure(_) => false
50+
})
51+
.toList
52+
ClassFinder.classInfoMap(classes.iterator)
4153
}
4254

4355
private[this] def subclassesOf[A: ClassTag](cl: ClassLoader): List[String] = {
@@ -46,9 +58,11 @@ object Exercises {
4658
case None acc
4759
case Some(cll: URLClassLoader)
4860
val cn = ClassFinder
49-
.concreteSubclasses(implicitly[ClassTag[A]].runtimeClass.getName, classMap(cll))
50-
.filter(_.name.startsWith(LIBRARIES_PACKAGE))
51-
.map(_.name)
61+
.concreteSubclasses("org.scalaexercises.runtime.model.Library", classMap(cll))
62+
.map { classInfo =>
63+
println(classInfo)
64+
classInfo.name
65+
}
5266
.toList
5367
loop(currentClassLoader.getParent, acc ++ cn)
5468
case Some(o) loop(o.getParent, acc)

src/test/scala/com/fortysevendeg/exercises/Content.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* scala-exercises
33
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
4+
* Copyright 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

src/test/scala/com/fortysevendeg/exercises/ExampleTarget.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* scala-exercises
33
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
4+
* Copyright 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

src/test/scala/com/fortysevendeg/exercises/LibraryDiscoverySpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* scala-exercises
33
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
4+
* Copyright 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

src/test/scala/com/fortysevendeg/exercises/TimestampSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* scala-exercises
33
*
4-
* Copyright 2015-2017 47 Degrees, LLC. <http://www.47deg.com>
4+
* Copyright 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)