My azure release pipeline is working fine when I run individual salesforce test suit image 1 attached. But when I combine multiple salesforce test suit into under "variables" section in azure release pipeline, it getting failed image 2 attached
Logs image attached for the reference [Note - XXX is mentioned to hide the sensitive items) image 3 attached. Version are mentioned clearly in pom.xml so no issue there. Any help on this highly appreciable.
Log added here as requested by Dan in comments section.
2021-09-22T12:46:11.7887285Z Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
2021-09-22T12:46:11.7887560Z
2021-09-22T12:46:11.8032623Z [INFO] ------------------------------------------------------------------------
2021-09-22T12:46:11.8033084Z [INFO] Reactor Summary:
2021-09-22T12:46:11.8033498Z [INFO]
2021-09-22T12:46:11.8033912Z [INFO] xxxx.salesforce.regression 1.0 ..................... SUCCESS [ 1.050 s]
2021-09-22T12:46:11.8041862Z [INFO] xxxx.regression.core 0.0.1-SNAPSHOT ................ SUCCESS [ 1.425 s]
2021-09-22T12:46:11.8047350Z [INFO] xxxx.salesforce.regression.api 0.0.1-SNAPSHOT ...... SUCCESS [ 6.110 s]
2021-09-22T12:46:11.8049728Z [INFO] xxxx.salesforce.regression.framework 0.0.1-SNAPSHOT SUCCESS [ 17.345 s]
2021-09-22T12:46:11.8055798Z [INFO] xxxx.salesforce.regression.script 0.0.1-SNAPSHOT ... FAILURE [01:17 min]
2021-09-22T12:46:11.8060546Z [INFO] ------------------------------------------------------------------------
2021-09-22T12:46:11.8061249Z [INFO] BUILD FAILURE
2021-09-22T12:46:11.8068152Z [INFO] ------------------------------------------------------------------------
2021-09-22T12:46:11.8072043Z [INFO] Total time: 01:43 min
2021-09-22T12:46:11.8077042Z [INFO] Finished at: 2021-09-22T08:46:11-04:00
2021-09-22T12:46:11.8079514Z [INFO] ------------------------------------------------------------------------
2021-09-22T12:46:11.8121567Z [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project xxxx.salesforce.regression.script:
Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
2021-09-22T12:46:11.8123247Z [ERROR] java.lang.RuntimeException: Unable to load category: RegressionBrokerCommunityCensusScripts
2021-09-22T12:46:11.8132417Z [ERROR] at org.apache.maven.surefire.group.match.SingleGroupMatcher.loadGroupClasses(SingleGroupMatcher.java:139)
2021-09-22T12:46:11.8135200Z [ERROR] at org.apache.maven.surefire.group.match.JoinGroupMatcher.loadGroupClasses(JoinGroupMatcher.java:49)
2021-09-22T12:46:11.8139427Z [ERROR] at org.apache.maven.surefire.common.junit48.FilterFactory.createGroupFilter(FilterFactory.java:100)
2021-09-22T12:46:11.8144812Z [ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreProvider.createJUnit48Filter(JUnitCoreProvider.java:279)
2021-09-22T12:46:11.8169178Z [ERROR] at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:130)
2021-09-22T12:46:11.8170407Z [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
2021-09-22T12:46:11.8171319Z [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
2021-09-22T12:46:11.8171999Z [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
2021-09-22T12:46:11.8176714Z [ERROR] Caused by: java.lang.ClassNotFoundException: RegressionBrokerCommunityCensusScripts
2021-09-22T12:46:11.8177403Z [ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
2021-09-22T12:46:11.8191357Z [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
2021-09-22T12:46:11.8191846Z [ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
2021-09-22T12:46:11.8210436Z [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
2021-09-22T12:46:11.8212191Z [ERROR] at org.apache.maven.surefire.group.match.SingleGroupMatcher.loadGroupClasses(SingleGroupMatcher.java:135)
2021-09-22T12:46:11.8212992Z [ERROR] ... 7 more
2021-09-22T12:46:11.8213257Z [ERROR]
2021-09-22T12:46:11.8213629Z [ERROR] -> [Help 1]
2021-09-22T12:46:11.8214006Z [ERROR]
2021-09-22T12:46:11.8214686Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2021-09-22T12:46:11.8215594Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2021-09-22T12:46:11.8216175Z [ERROR]
2021-09-22T12:46:11.8218205Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2021-09-22T12:46:11.8219550Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
2021-09-22T12:46:11.8220244Z [ERROR]
2021-09-22T12:46:11.8221416Z [ERROR] After correcting the problems, you can resume the build with the command
2021-09-22T12:46:11.8224889Z [ERROR] mvn <args> -rf :xxxx.salesforce.regression.script
2021-09-22T12:46:12.1235561Z The process 'D:\Tools\apache-maven-3.6.3\bin\mvn.cmd' failed with exit code 1
2021-09-22T12:46:12.1239927Z Could not retrieve code analysis results - Maven run failed.
2021-09-22T12:46:13.8305598Z No test result files matching D:\agents\A5\_wk\r4\a\**\surefire-reports\TEST-*.xml were found, so publishing JUnit test results is being skipped.
2021-09-22T12:46:13.8351432Z ##[error]Build failed.
I am working on Rocket Chip Generator, which is a SoC written in Chisel.
My objective is to extract the Floating-Point Unit, in order to synthesize it and study its power consumption/area ...etc. separately from the rest of the SoC.
So I cloned the project and tried to create a dedicated TestHarness where I only instanciate an FPU. This is an example code of what I did (very similar to TestHarness
package freechips.rocketchip.system
import Chisel._
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.devices.debug.Debug
import freechips.rocketchip.diplomacy.LazyModule
import freechips.rocketchip.rocket._
// importing FPU class
import freechips.rocketchip.tile._
class FPUTestHarness() (implicit p: Parameters) extends Module {
val io = new Bundle {
val dummyIn = Bool(INPUT)
val dummyOut = Bool(OUTPUT)
}
// The parameters of the FPU
val fpu_params = FPUParams(
fLen = 32 // default is 64
divSqrt = false // default is true
// sfmaLatency = 3, // default
// dfmaLatency = 4 // default
)
val fpu = Module(new FPU(fpu_params)(p))
}
The problem is that the implicit parameter p (of type Parameters) doesn't contain something called TileKey, which is needed I don't know where. Apparently the implicit parameter p, passed to FPUTestHarness doesn't contain that information. How can I resolve that? Is it possible to hardcode that somewhere for example?
rocket-chip-new/vsim$ make verilog
mkdir -p /home/mylab/rocket-chip/vsim/generated-src/
cd /home/mylab/rocket-chip && java -Xmx2G -Xss8M -XX:MaxPermSize=256M -jar /home/mylab/rocket-chip/sbt-launch.jar "runMain freechips.rocketchip.system.Generator /home/mylab/rocket-chip/vsim/generated-src freechips.rocketchip.system FPUTestHarness freechips.rocketchip.system DefaultConfig"
OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
[info] Loading settings for project rocket-chip-new-build from plugins.sbt ...
[info] Loading project definition from /home/mylab/rocket-chip/project
[info] Loading settings for project rocketchip from build.sbt ...
[info] Loading settings for project hardfloat from build.sbt ...
[info] Loading settings for project chisel from build.sbt ...
Using addons:
[info] Set current project to rocketchip (in build file:/home/mylab/rocket-chip/)
[info] Compiling 1 Scala source to /home/mylab/rocket-chip/target/scala-2.12/classes ...
[warn] there were two feature warnings; re-run with -feature for details
[warn] one warning found
[info] Done compiling.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/aitsaidn/.sbt/boot/scala-2.12.7/org.scala-sbt/sbt/1.2.7/protobuf-java-3.3.1.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
[info] Packaging /home/mylab/rocket-chip/target/scala-2.12/rocketchip_2.12-1.2-SNAPSHOT.jar ...
[info] Done packaging.
[info] Running freechips.rocketchip.system.Generator /home/mylab/rocket-chip/vsim/generated-src freechips.rocketchip.system FPUTestHarness freechips.rocketchip.system DefaultConfig
[info] [0.003] Elaborating design...
List(RocketTileParams(RocketCoreParams(0,true,false,true,true,false,true,false,0,1,false,8,0,true,false,true,0,Some(0),true,true,false,false,false,0,538447876,Some(MulDivParams(8,1,true,true,1)),Some(FPUParams(64,true,3,4))),Some(ICacheParams(64,4,64,32,0,None,None,None,false,64,2,4)),Some(DCacheParams(64,4,64,32,None,None,1,0,17,16,1,64,false,false,false,false,None)),Some(BTBParams(28,14,6,6,Some(BHTParams(512,1,8,3)),false)),0,Some(tile),0,None,None,false))
[error] (run-main-0) java.lang.reflect.InvocationTargetException
[error] java.lang.reflect.InvocationTargetException
[error] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error] at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
[error] at freechips.rocketchip.util.HasGeneratorUtilities.$anonfun$elaborate$1(GeneratorUtils.scala:54)
[error] at chisel3.core.Module$.do_apply(Module.scala:52)
[error] at chisel3.Driver$.$anonfun$elaborate$1(Driver.scala:95)
[error] at chisel3.internal.Builder$.$anonfun$build$2(Builder.scala:343)
[error] at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[error] at chisel3.internal.Builder$.$anonfun$build$1(Builder.scala:341)
[error] at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[error] at chisel3.internal.Builder$.build(Builder.scala:341)
[error] at chisel3.Driver$.elaborate(Driver.scala:95)
[error] at freechips.rocketchip.util.HasGeneratorUtilities.elaborate(GeneratorUtils.scala:59)
[error] Caused by: java.lang.IllegalArgumentException: requirement failed: Key TileKey is not defined in Parameters
[error] at scala.Predef$.require(Predef.scala:277)
[error] at freechips.rocketchip.config.View.apply(Config.scala:15)
[error] at freechips.rocketchip.config.View.apply(Config.scala:12)
[error] at freechips.rocketchip.tile.HasNonDiplomaticTileParameters.tileParams(BaseTile.scala:37)
[error] at freechips.rocketchip.tile.HasNonDiplomaticTileParameters.tileParams$(BaseTile.scala:37)
[error] at freechips.rocketchip.tile.CoreModule.tileParams(Core.scala:90)
[error] at freechips.rocketchip.tile.HasCoreParameters.$init$(Core.scala:51)
[error] at freechips.rocketchip.tile.CoreModule.<init>(Core.scala:90)
[error] at freechips.rocketchip.tile.FPUModule.<init>(FPU.scala:378)
[error] at freechips.rocketchip.tile.FPU.<init>(FPU.scala:661)
[error] at freechips.rocketchip.system.FPUTestHarness.$anonfun$fpu$1(FPUTestHarness.scala:71)
[error] at chisel3.core.Module$.do_apply(Module.scala:52)
[error] at freechips.rocketchip.system.FPUTestHarness.<init>(FPUTestHarness.scala:71)
[error] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] Nonzero exit code: 1
[error] (Compile / runMain) Nonzero exit code: 1
[error] Total time: 6 s, completed Jul 25, 2019, 7:59:01 PM
/home/mylab/rocket-chip/vsim/Makefrag-verilog:12: recipe for target '/home/mylab/rocket-chip/vsim/generated-src/freechips.rocketchip.system.DefaultConfig.fir' failed
make: *** [/home/mylab/rocket-chip/vsim/generated-src/freechips.rocketchip.system.DefaultConfig.fir] Error 1
It seems that you use the config as "DefaultConfig". Error log states that you did not specify TileKey parameter in this config. Adding TileKey parameter will resolve the issue. DefaultConfig is defined in rocket-chip/src/main/scala/system/Configs.scala
I want to run this SBT command in Ammonite:
sbt -mem 3000 clean compile docker:publishLocal
I tried a few things like:
%.sbt("-mem 3000", 'clean, 'test)(pwd)
Which gives this exception:
[error] Expected symbol
[error] Not a valid command: -
[error] Expected end of input.
[error] Expected '--'
[error] Expected 'debug'
[error] Expected 'info'
[error] Expected 'warn'
[error] Expected 'error'
[error] Expected 'addPluginSbtFile'
[error] -mem 3000
[error] ^
How is this done?
I recently had to the same thing, and i can tell you that is not fun when those "random" errors happen.
// I had to put the full path where sbt is, like this
val SBT = "C:\\Program Files (x86)\\sbt\\bin\\sbt.bat"
%(SBT, "-mem", "3000", "clean", "compile", "docker:publishLocal")(pwd)
with this the solution is:
%.sbt("-mem", "3000", 'clean, 'test)(pwd)
sbt-version: 1.2.1
scala-version: 2.12.6
i can connect ensime with emacs but once run C-C C-B c (ensime-sbt-do-compile) then encounter the following error
[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.IllegalArgumentException: Invalid terminal type:
at jline.TerminalFactory.create(TerminalFactory.java:103)
at jline.TerminalFactory.get(TerminalFactory.java:180)
at jline.TerminalFactory.get(TerminalFactory.java:186)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:244)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:236)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:228)
at sbt.internal.util.JLine$.$anonfun$createReader$1(LineReader.scala:137)
at sbt.internal.util.JLine$.$anonfun$usingTerminal$1(LineReader.scala:128)
at sbt.internal.util.JLine$.withTerminal(LineReader.scala:118)
at sbt.internal.util.JLine$.usingTerminal(LineReader.scala:126)
at sbt.internal.util.JLine$.createReader(LineReader.scala:136)
at sbt.internal.util.SimpleReader.<init>(LineReader.scala:213)
at sbt.internal.util.SimpleReader$.<init>(LineReader.scala:216)
at sbt.internal.util.SimpleReader$.<clinit>(LineReader.scala)
at sbt.Import.$init$(Import.scala:179)
at sbt.package$.<init>(package.scala:11)
at sbt.package$.<clinit>(package.scala)
at $0c1c090d12f59c194554$.$sbtdef(C:\Users\xxx\.sbt\1.0\plugins\build.sbt:1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.compiler.Eval$.getValue(Eval.scala:578)
at sbt.compiler.Eval.$anonfun$eval$1(Eval.scala:129)
at sbt.internal.EvaluateConfigurations$.$anonfun$evaluateDslEntry$1(EvaluateConfigurations.scala:249)
at sbt.internal.EvaluateConfigurations$.$anonfun$evaluateSbtFile$6(EvaluateConfigurations.scala:172)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.immutable.List.foreach(List.scala:389)
at scala.collection.TraversableLike.map(TraversableLike.scala:234)
at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
at scala.collection.immutable.List.map(List.scala:295)
at sbt.internal.EvaluateConfigurations$.$anonfun$evaluateSbtFile$4(EvaluateConfigurations.scala:172)
at sbt.internal.Load$.loadSettingsFile$1(Load.scala:1137)
at sbt.internal.Load$.$anonfun$discoverProjects$2(Load.scala:1144)
at scala.collection.MapLike.getOrElse(MapLike.scala:128)
at scala.collection.MapLike.getOrElse$(MapLike.scala:126)
at scala.collection.AbstractMap.getOrElse(Map.scala:59)
at sbt.internal.Load$.memoLoadSettingsFile$1(Load.scala:1143)
at sbt.internal.Load$.$anonfun$discoverProjects$4(Load.scala:1151)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.immutable.List.foreach(List.scala:389)
at scala.collection.TraversableLike.map(TraversableLike.scala:234)
at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
at scala.collection.immutable.List.map(List.scala:295)
at sbt.internal.Load$.loadFiles$1(Load.scala:1151)
at sbt.internal.Load$.discoverProjects(Load.scala:1165)
at sbt.internal.Load$.discover$1(Load.scala:862)
at sbt.internal.Load$.loadTransitive(Load.scala:937)
at sbt.internal.Load$.loadProjects$1(Load.scala:726)
at sbt.internal.Load$.$anonfun$loadUnit$11(Load.scala:729)
at sbt.internal.Load$.timed(Load.scala:1395)
at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:729)
at sbt.internal.Load$.timed(Load.scala:1395)
at sbt.internal.Load$.loadUnit(Load.scala:688)
at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:484)
at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:176)
at sbt.internal.BuildLoader.apply(BuildLoader.scala:241)
at sbt.internal.Load$.loadURI$1(Load.scala:546)
at sbt.internal.Load$.loadAll(Load.scala:562)
at sbt.internal.Load$.loadURI(Load.scala:492)
at sbt.internal.Load$.load(Load.scala:471)
at sbt.internal.Load$.$anonfun$apply$1(Load.scala:251)
at sbt.internal.Load$.timed(Load.scala:1395)
at sbt.internal.Load$.apply(Load.scala:251)
at sbt.internal.GlobalPlugin$.build(GlobalPlugin.scala:59)
at sbt.internal.GlobalPlugin$.load(GlobalPlugin.scala:64)
at sbt.internal.Load$.loadGlobal(Load.scala:193)
at sbt.internal.Load$.defaultWithGlobal(Load.scala:150)
at sbt.internal.Load$.$anonfun$defaultLoad$1(Load.scala:64)
at sbt.internal.Load$.timed(Load.scala:1395)
at sbt.internal.Load$.defaultLoad(Load.scala:60)
at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:829)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:829)
at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:800)
at sbt.Command$.$anonfun$applyEffect$4(Command.scala:142)
at sbt.Command$.$anonfun$applyEffect$2(Command.scala:137)
at sbt.Command$.process(Command.scala:181)
at sbt.MainLoop$.processCommand(MainLoop.scala:151)
at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:139)
at sbt.State$$anon$1.runCmd$1(State.scala:246)
at sbt.State$$anon$1.process(State.scala:250)
at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:139)
at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
at sbt.MainLoop$.next(MainLoop.scala:139)
at sbt.MainLoop$.run(MainLoop.scala:132)
at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:110)
at sbt.io.Using.apply(Using.scala:22)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:104)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:59)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:44)
at sbt.MainLoop$.runLogged(MainLoop.scala:35)
at sbt.StandardMain$.runManaged(Main.scala:138)
at sbt.xMain.run(Main.scala:89)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:56)
at xsbt.boot.Boot$.main(Boot.scala:18)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException:
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at jline.TerminalFactory.create(TerminalFactory.java:100)
... 101 more
[info] Loading settings for project global-plugins from build.sbt,plugins.sbt ...
[info] Loading global plugins from C:\Users\xxx\.sbt\1.0\plugins
[info] Loading project definition from C:\Users\xxx\ScalaProjects\minedemo\hello\project
[info] Loading settings for project hello from build.sbt ...
[info] Set current project to hello-world (in build file:/C:/Users/xxx/ScalaProjects/minedemo/hello/)
[error] Not a valid command: none (similar: new)
[error] Not a valid project ID: none
[error] Expected ':'
[error] Not a valid key: none (similar: runner, name, console)
[error] none
[error] ^
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
i am not sure whether it's emacs config issue or sbt config issue , i am newer for scala and emacs, very appreciate for any help, it block me lots of time
found a solution from emacs-sbt-mode
https://github.com/ensime/emacs-sbt-mode/issues/120
(setq sbt:program-options '())
Works for me on:
OS: Windows 10 x64 edition
SBT: 1.2.8
JDK: 1.8.0_211
Emacs: 26.2.90 (build 2, x86_64-w64-mingw32) of 2019-06-14
sbt-mode: 2.0.0
scala-mode: 1.0.0
ensime: 2.0.2
After adding the following method to map case classes to Map or js.Dictionary - and I've tried now five or six variants of the following - my code compiles fine and without warnings, but then hits errors at the fastOptJS sjs linking stage.
The method
def ccToMap(cc: AnyRef) =
(Map[String, Any]() /: cc.getClass.getDeclaredFields) {
(a, f) =>
f.setAccessible(true)
a + (f.getName -> f.get(cc))
}
Note that all the variants I have tried do the same thing in a slightly different manner.
The error
[info] Fast optimizing /Users/justin/Desktop/arete/jt/client/target/scala-2.11/client-fastopt.js
[error] Referring to non-existent class java.lang.reflect.Field
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.ccToMap(java.lang.Object)scala.collection.immutable.Map
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.<init>()
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(japgolly.scalajs.react.extra.router.RouterCtl)japgolly.scalajs.react.ReactElement
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(java.lang.Object)java.lang.Object
[error] called from scala.collection.LinearSeqOptimized$class.foreach(scala.collection.LinearSeqOptimized,scala.Function1)scala.Unit
[error] called from scala.collection.mutable.MutableList.foreach(scala.Function1)scala.Unit
[error] called from scala.collection.TraversableLike$WithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from scala.collection.immutable.Stream$StreamWithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from org.scalajs.testinterface.internal.Slave.org$scalajs$testinterface$internal$Slave$$execute(scala.scalajs.js.Dynamic)scala.Unit
[error] called from org.scalajs.testinterface.internal.Slave.handleMsgImpl(java.lang.String,scala.Function0)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.handleMsg(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$anonfun$1(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.init()scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$js$exported$meth$init()java.lang.Object
[error] called from org.scalajs.testinterface.internal.BridgeBase.init
[error] exported to JavaScript with #JSExport
[error] involving instantiated classes:
[error] com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$
[error] com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2
[error] scala.collection.mutable.Queue
[error] scala.collection.mutable.MutableList
[error] scala.collection.TraversableLike$WithFilter
[error] scala.collection.immutable.Stream$StreamWithFilter
[error] org.scalajs.testinterface.internal.Slave
[error] org.scalajs.testinterface.internal.Master
[error] Referring to non-existent method java.lang.Class.getDeclaredFields() [java.lang.reflect.Field
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.ccToMap(java.lang.Object)scala.collection.immutable.Map
[error] called from com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$.<init>()
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(japgolly.scalajs.react.extra.router.RouterCtl)japgolly.scalajs.react.ReactElement
[error] called from com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2.apply(java.lang.Object)java.lang.Object
[error] called from scala.collection.LinearSeqOptimized$class.foreach(scala.collection.LinearSeqOptimized,scala.Function1)scala.Unit
[error] called from scala.collection.mutable.MutableList.foreach(scala.Function1)scala.Unit
[error] called from scala.collection.TraversableLike$WithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from scala.collection.immutable.Stream$StreamWithFilter.map(scala.Function1,scala.collection.generic.CanBuildFrom)java.lang.Object
[error] called from org.scalajs.testinterface.internal.Slave.org$scalajs$testinterface$internal$Slave$$execute(scala.scalajs.js.Dynamic)scala.Unit
[error] called from org.scalajs.testinterface.internal.Slave.handleMsgImpl(java.lang.String,scala.Function0)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.handleMsg(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$anonfun$1(java.lang.String)scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.init()scala.Unit
[error] called from org.scalajs.testinterface.internal.BridgeBase.$$js$exported$meth$init()java.lang.Object
[error] called from org.scalajs.testinterface.internal.BridgeBase.init
[error] exported to JavaScript with #JSExport
[error] involving instantiated classes:
[error] com.jshin47.jtdc.client.module.visualization.DiodeStateVizC$
[error] com.jshin47.jtdc.client.module.landing.LandingLocC$$anonfun$2
[error] scala.collection.mutable.Queue
[error] scala.collection.mutable.MutableList
[error] scala.collection.TraversableLike$WithFilter
[error] scala.collection.immutable.Stream$StreamWithFilter
[error] org.scalajs.testinterface.internal.Slave
[error] org.scalajs.testinterface.internal.Master
[trace] Stack trace suppressed: run last client/compile:fastOptJS for the full output.
[error] (client/compile:fastOptJS) There were linking errors
[error] Total time: 36 s, completed May 10, 2016 2:01:07 AM
What I've tried
Being unfamiliar with the details of the linker I am only able to try some "obvious" diagnostics:
Whether I call the method or not, this error is thrown (it doesn't have to be in the code path, so this is getting thrown when the method itself is linked)
The Map type itself works just fine as an argument to the function where I am trying to invoke this
I know to a certainty that iff this method (or similar) is present, then I get the above linker error. (Without, no error.)
Any tips on how to proceed, debug, etc are appreciated.
Alternatively, any tips on how I may convert a case class to a Map without the above-style (reflection-based) function, please let me know
You simply can't use Java reflection in Scala.js:
Java reflection and, a fortiori, Scala reflection, are not supported. There is limited support for java.lang.Class, e.g., obj.getClass.getName will work for any Scala.js object (not for objects that come from JavaScript interop).
Use macros for this instead. See e.g. Scala Macros: Making a Map out of fields of a class in Scala