Backporting collection of Statistics for Scala 2.11.x

I’ve tried to use this project, but since it requires the project to profile to use scala 2.12.x and given my current project is big and won’t be easy to migrate.

I went and review the work from @jvican that was merged in 2.12, I started rebasing it into the 2.11 branch, I cherry-picked the commits and made them compatible to source and target jvm versions.
However I’ve hit a wall when rebuilding the compiler and I need some help into what is the best direction to take here.

Currently the issue right now is in the class scala.reflect.internal.util.AlmostFinalValue, the package java.lang.invoke is used extensively, specially the MethodHandle is the one that throws an error when rebuilding the compiler.

I’ve been looking for a way to downgrade this code to be jdk6 compatible but still not luck.

Here is the error message that I get:

~/var/www/foss/scala • ant
Buildfile: /Users/raul/var/www/foss/scala/build.xml




     [copy] Copying 2 files to /Users/raul/var/www/foss/scala/build/deps/junit
     [copy] Copying 28 files to /Users/raul/var/www/foss/scala/build/deps/pax.exam
     [copy] Copying 4 files to /Users/raul/var/www/foss/scala/build/deps/partest
     [copy] Copying 1 file to /Users/raul/var/www/foss/scala/build/deps/repl
     [copy] Copying 5 files to /Users/raul/var/www/foss/scala/build/deps/scaladoc
     [echo] Using Scala 2.11.5 for STARR.
     [copy] Copying 5 files to /Users/raul/var/www/foss/scala/build/deps/starr
     [echo]        build time: 6 January 2018, 23:30:49
     [echo]      java version: Java HotSpot(TM) 64-Bit Server VM 1.8.0_152-ea (1.8)
     [echo]         java args: -Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=192M -XX:+UseParallelGC
     [echo]        javac args:
     [echo]       scalac args: -feature
     [echo] scalac quick args: -feature
     [echo]          git date: 20180106-001229
     [echo]          git hash: 43f6e4508a
     [echo]     maven version: 2.11.6-SNAPSHOT
     [echo]      OSGi version: 2.11.6.v20180106-001229-43f6e4508a
     [echo] canonical version: 2.11.6-20180106-001229-43f6e4508a





    [javac] Compiling 1 source file to /Users/raul/var/www/foss/scala/build/locker/classes/reflect
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    [javac] /Users/raul/var/www/foss/scala/src/reflect/scala/reflect/internal/util/ error: method invoked with incorrect number of arguments; expected 0, found 1
    [javac]       return ((BooleanContainer)(Object) COLD_STATS_GETTER.invokeExact()).isEnabledNow();
    [javac]                                                                       ^

/Users/raul/var/www/foss/scala/build.xml:1092: The following error occurred while executing this line:
/Users/raul/var/www/foss/scala/build-ant-macros.xml:275: The following error occurred while executing this line:
/Users/raul/var/www/foss/scala/build-ant-macros.xml:282: The following error occurred while executing this line:
/Users/raul/var/www/foss/scala/build-ant-macros.xml:135: Compile failed; see the compiler error output for details.

Total time: 3 seconds

First things first, are you sure your project will be more difficult to upgrade to Scala 2.12 than what you’re doing now?

1 Like

Hi @yawaramin,

Yes, it’s a large codebase and while the upgrade will happen, there is no deadline to do it, maybe 2nd or 3rd quarter being optimistic.

In the meantime, I believe it would be great to have this feature implemented somehow.

Currently, I’m exploring if maybe I can create a compiler plugin to achieve the same result?