scalastuff / scalabeans Goto Github PK
View Code? Open in Web Editor NEWScala reflection and serialization library
Home Page: http://scalabeans.googlecode.com
License: Apache License 2.0
Scala reflection and serialization library
Home Page: http://scalabeans.googlecode.com
License: Apache License 2.0
When I reflect over a case class
case class UnicodePropetyCaseClass(`class-id`: Int, name: String)
then the bean descriptor only has the name property.
Could it be more appropriate to use scala.reflect.NameTransformer.decode
so the class name can be unmangled?
Then it would pass this test: https://github.com/scalastuff/scalabeans/blob/master/src/main/scala/org/scalastuff/scalabeans/BeanIntrospector.scala#L105
but that will most likely break other things
The weak key is an instance of ScalaType and the strong value is an instance of ClassInfo that refers to the same ScalaType instance so the keys are always strongly reachable via the value.
This example gives IllegalArgumentException:
case class FixtureWithArray(key:UUID, content:Array[Byte])
val descriptor = descriptorOf[FixtureWithArray]
val builder = descriptor.newBuilder()
builder.set(descriptor("key"),UUID.randomUUID())
builder.set(descriptor("content"),Array.empty[Byte])
val instance = builder.result().asInstanceOf[FixtureWithArray]
The problem is that constructor signature has Scala Array[Byte] type, while compile code has Java type byte[] and paranamer cannot find it. Only workaround at the moment is to get rid of all arrays in the constructor.
Hi,
I can see that it's using scala 2.9 and PickleFormat for instance, that is no longer supported in latest scala versions.
Is there any plan to update the project or is it staled?
This REPL transcript uses the source cloned from Github (at the time of writing).
scala> import org.scalastuff.scalabeans.Preamble._
import org.scalastuff.scalabeans.Preamble._
scala> import scala.collection._
import scala.collection._
scala> classOf[SortedMap[String,String]]
res0: java.lang.Class[scala.collection.SortedMap[String,String]] = interface scala.collection.SortedMap
scala> descriptorOf(res0)
java.lang.NullPointerException
at org.scalastuff.scalabeans.BeanIntrospector$.classExtent$1(BeanIntrospector.scala:40)
at org.scalastuff.scalabeans.BeanIntrospector$.classExtent$1(BeanIntrospector.scala:40)
at org.scalastuff.scalabeans.BeanIntrospector$.apply(BeanIntrospector.scala:101)
at org.scalastuff.scalabeans.Preamble$.descriptorOf(Preamble.scala:31)
at .<init>(<console>:15)
at .<clinit>(<console>)
at .<init>(<console>:11)
at .<clinit>(<console>)
at $export(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:592)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$10.apply(IMain.scala:828)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:31)
at java.lang.Thread.run(Thread.java:680)
I have a class as ..
case class ContactWithOptionalAddr(name: String, addresses: Option[Map[String, Address]])
When I do a
import org.scalastuff.scalabeans.Preamble._
val descriptor = descriptorOf[ContactWithOptionalAddr]
for (property <- descriptor.properties)
println(property.name + ": " + property.scalaType)
I get ..
name: String
addresses: Option[Map[Tuple2[String,Address]]]
which is not correct .. the Tuple2 I mean .. help ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.