Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThreadPoolConfig.useForkJoin defaults to false on the new 1.7JDK #4960

Closed
scabug opened this issue Sep 1, 2011 · 5 comments
Closed

ThreadPoolConfig.useForkJoin defaults to false on the new 1.7JDK #4960

scabug opened this issue Sep 1, 2011 · 5 comments
Assignees

Comments

@scabug
Copy link

scabug commented Sep 1, 2011

Unfortunately the vendor of the 1.7VM has changed from "Sun Microsystems Inc." to "Oracle Corporation". This means that the fork-join-pool is not enabled by default

Welcome to Scala version 2.9.1.final (Java HotSpot(TM) Server VM, Java 1.7.0).
Type in expressions to have them evaluated.
Type :help for more information.

scala>  System.getProperty("java.vm.vendor")
res0: java.lang.String = Oracle Corporation

See this code:

private[actors] def useForkJoin: Boolean =
    try !propIsSetTo("actors.enableForkJoin", "false") &&
      (propIsSetTo("actors.enableForkJoin", "true") || {
        Debug.info(this+": java.version = "+javaVersion)
        Debug.info(this+": java.vm.vendor = "+javaVmVendor)
      
        // on IBM J9 1.6 do not use ForkJoinPool
        // XXX this all needs to go into Properties.
        isJavaAtLeast("1.6") && ((javaVmVendor contains "Sun") || (javaVmVendor contains "Apple"))
      })
    catch {
      case _: SecurityException => false
    }

The fix is trivial

@scabug
Copy link
Author

scabug commented Sep 1, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4960?orig=1
Reporter: @oxbowlakes
Affected Versions: 2.9.1

@scabug
Copy link
Author

scabug commented Nov 11, 2011

@SethTisue said:
doh! good catch!

@scabug
Copy link
Author

scabug commented Nov 11, 2011

@axel22 said:
Any reason this wasn't fixed for so long (because it should be a trivial one-liner)?
If there is no reason, I'm about to commit the fix now.

@scabug
Copy link
Author

scabug commented Nov 11, 2011

@axel22 said:
Fixed in r25989.

@scabug scabug closed this as completed Nov 11, 2011
@scabug
Copy link
Author

scabug commented Apr 12, 2013

@retronym said (edited on Apr 12, 2013 1:30:40 PM UTC):
Workaround for anyone still stuck on 2.9.1:

scala> val cls = scala.collection.parallel.`package`.getClass
cls: java.lang.Class[_ <: object scala.collection.parallel.package] = class scala.collection.parallel.package$

scala> val fld = cls.getDeclaredField("tasksupport")
fld: java.lang.reflect.Field = private final scala.collection.parallel.TaskSupport scala.collection.parallel.package$.tasksuppo

scala> fld.setAccessible(true)

scala> val const = Class.forName("scala.collection.parallel.ForkJoinTaskSupport").getDeclaredConstructors.head
const: java.lang.reflect.Constructor[_] = public scala.collection.parallel.ForkJoinTaskSupport()

scala> const.setAccessible(true)

scala> val support = const.newInstance()
support: Any = scala.collection.parallel.ForkJoinTaskSupport@1d0c2dea

scala> fld.set(scala.collection.parallel.`package`, support)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants