The following works fine in Scala 2.11.8, do you know any workaround for 2.13.10?
$ ./scala
Welcome to Scala 2.13.10 (Java HotSpot™ 64-Bit Server VM, Java 17.0.6).
Type in expressions for evaluation. Or try :help.
scala> val tt = Class.forName(“scala.reflect.ClassTag$$anon$1”)
java.lang.ClassNotFoundException: scala.reflect.ClassTag$$anon$1
at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:75)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
… 32 elided
I’m not sure what’s your use case but it seems that you were refering to ClassTag.GenericClassTag. It’s still present in Scala 2.12 as annonymous class, but in Scala 2.13 it’s encoded as scala.reflect.ClassTag$GenericClassTag
Thanks! it works for me. I use it to initialize some spark stuff (we have upgraded Spark and scala):
kryo.register(Class.forName(“scala.reflect.ClassTag$GenericClassTag”))
Probably you refer to val f = () => {...} in KafkaSink.apply. $anonfun" is an anonymous function. As far I know since 2.12 their encoding has change. Before each anonymous function was encoded as new anonymous class (that’s what we still do in Scala Native). Since 2.12 on the JVM they probably use standard Java 8 lambdas support, though there would be no $anonfun$ class anymore.
Anyway refering to anonymous stuff via reflection is ultra-unsafe. In theory that’s the implementation detail and could change at any moment.If possible, it would be better to refactor the code the remove unsafe, reflection based access.