Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
some changes so it compiles on Java 9
Browse files Browse the repository at this point in the history
we don't really strictly need partest to compile on Java 9,
but the needed changes are small

this came up in the context of the Scala 2.12-on-Java-9 community build
  • Loading branch information
SethTisue committed May 21, 2018
1 parent b0cc1b6 commit 3b1ab83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version=0.13.15
sbt.version=0.13.17
7 changes: 6 additions & 1 deletion src/main/scala/scala/tools/partest/nest/StreamCapture.scala
Expand Up @@ -41,7 +41,12 @@ object StreamCapture {
def withExtraProperties[A](extra: Map[String, String])(action: => A): A = {
val saved = System.getProperties()
val modified = new java.util.Properties()
modified.putAll(saved)
// on Java 9, we need to cast our way around this:
// src/main/scala/scala/tools/partest/nest/StreamCapture.scala:44: ambiguous reference to overloaded definition,
// both method putAll in class Properties of type (x$1: java.util.Map[_, _])Unit
// and method putAll in class Hashtable of type (x$1: java.util.Map[_ <: Object, _ <: Object])Unit
// match argument types (java.util.Properties)
(modified: java.util.Hashtable[AnyRef, AnyRef]).putAll(saved)
extra.foreach { case (k, v) => modified.setProperty(k, v) }
// Trying to avoid other threads seeing the new properties object prior to the new entries
// https://github.com/scala/scala/pull/6391#issuecomment-371346171
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scala/tools/partest/package.scala
Expand Up @@ -97,7 +97,7 @@ package object partest {
*/
def instantiate[A >: Null](name: String): A = (
catching(classOf[ClassNotFoundException], classOf[SecurityException]) opt
(loader loadClass name).newInstance.asInstanceOf[A] orNull
(loader loadClass name).getConstructor().newInstance().asInstanceOf[A] orNull
)
}

Expand Down

0 comments on commit 3b1ab83

Please sign in to comment.