Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Support for scala 2.10 #80

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 59 additions & 42 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</prerequisites>

<groupId>com.codahale</groupId>
<artifactId>jerkson_2.9.1</artifactId>
<artifactId>jerkson_2.10.1</artifactId>
<version>0.6.0-SNAPSHOT</version>
<name>Jerkson for Scala</name>

<properties>
<scala.version>2.9.1</scala.version>
<jackson.version>2.0.2</jackson.version>
<scala.version>2.10.1</scala.version>
<jackson.version>2.1.4</jackson.version>
</properties>

<developers>
Expand All @@ -39,10 +39,6 @@
<id>repo.codahale.com</id>
<url>http://repo.codahale.com</url>
</repository>
<repository>
<id>nativelibs4java</id>
<url>http://nativelibs4java.sourceforge.net/maven</url>
</repository>
</repositories>

<distributionManagement>
Expand All @@ -58,6 +54,11 @@
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand All @@ -69,9 +70,9 @@
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.codahale</groupId>
<artifactId>simplespec_${scala.version}</artifactId>
<version>0.5.2</version>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10.0</artifactId>
<version>1.8</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -107,11 +108,23 @@
</profiles>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution><id>default-compile</id><phase>none</phase></execution>
<execution><id>default-testCompile</id><phase>none</phase></execution>
</executions>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
Expand All @@ -121,29 +134,22 @@
</execution>
</executions>
<configuration>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<compileOrder>java-then-scala</compileOrder>
<jvmArgs>
<jvmArg>-Xms96m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
<args>
<arg>-optimise</arg>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-unchecked</arg>
<arg>-feature</arg>
<arg>-language:postfixOps</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:higherKinds</arg>
<arg>-language:reflectiveCalls</arg>
</args>
<compilerPlugins>
<compilerPlugin>
<groupId>com.nativelibs4java</groupId>
<artifactId>scalacl-compiler-plugin</artifactId>
<version>0.2</version>
</compilerPlugin>
</compilerPlugins>
<charset>UTF-8</charset>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
Expand All @@ -170,17 +176,28 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0-M2</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>-Xmx1024m</argLine>
<includes>
<include>**/*Spec.java</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/codahale/jerkson/AST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object AST {
try {
elements(index)
} catch {
case _ => JNull
case _: Throwable => JNull
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/codahale/jerkson/Generator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait Generator extends Factory {
/**
* Returns true if the given class is serializable.
*/
def canSerialize[A](implicit mf: Manifest[A]) = mapper.canSerialize(mf.erasure)
def canSerialize[A](implicit mf: Manifest[A]) = mapper.canSerialize(mf.runtimeClass)

private def generate[A](obj: A, generator: JsonGenerator) {
generator.writeObject(obj)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/codahale/jerkson/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ trait Parser extends Factory {

private[jerkson] def parse[A](parser: JsonParser, mf: Manifest[A]): A = {
try {
if (mf.erasure == classOf[JValue] || mf.erasure == JNull.getClass) {
if (mf.runtimeClass == classOf[JValue] || mf.runtimeClass == JNull.getClass) {
val value: A = parser.getCodec.readValue(parser, Types.build(mapper.getTypeFactory, mf))
if (value == null) JNull.asInstanceOf[A] else value
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/com/codahale/jerkson/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package com.codahale.jerkson

import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.`type`.{TypeFactory, ArrayType}
import scala.collection.JavaConversions.asScalaConcurrentMap
import scala.collection.JavaConversions.mapAsScalaConcurrentMap
import java.util.concurrent.ConcurrentHashMap

private[jerkson] object Types {
private val cachedTypes = asScalaConcurrentMap(new ConcurrentHashMap[Manifest[_], JavaType]())
private val cachedTypes = mapAsScalaConcurrentMap(new ConcurrentHashMap[Manifest[_], JavaType]())

def build(factory: TypeFactory, manifest: Manifest[_]): JavaType =
cachedTypes.getOrElseUpdate(manifest, constructType(factory, manifest))

private def constructType(factory: TypeFactory, manifest: Manifest[_]): JavaType = {
if (manifest.erasure.isArray) {
ArrayType.construct(factory.constructType(manifest.erasure.getComponentType), null, null)
if (manifest.runtimeClass.isArray) {
ArrayType.construct(factory.constructType(manifest.runtimeClass.getComponentType), null, null)
} else {
factory.constructParametricType(
manifest.erasure,
manifest.runtimeClass,
manifest.typeArguments.map {m => build(factory, m)}.toArray: _*)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EitherDeserializer(config: DeserializationConfig,
try {
Left(tp.getCodec.readValue[Object](tp, javaType.containedType(0)))
} catch {
case _ => Right(tp.getCodec.readValue[Object](tp, javaType.containedType(1)))
case _: Throwable => Right(tp.getCodec.readValue[Object](tp, javaType.containedType(1)))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.Module.SetupContext

class ScalaDeserializers(classLoader: ClassLoader, context: SetupContext) extends Deserializers.Base {
override def findBeanDeserializer(javaType: JavaType, config: DeserializationConfig,
beanDesc: BeanDescription) = {
beanDesc: BeanDescription): JsonDeserializer[_] = {
val klass = javaType.getRawClass
if (klass == classOf[Range] || klass == classOf[immutable.Range]) {
new RangeDeserializer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.codahale.jerkson.util.scalax.rules.scalasig._
import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.`type`.TypeFactory
import scala.reflect.ScalaSignature
import scala.reflect.generic.ByteCodecs
import scala.reflect.internal.pickling.ByteCodecs

class MissingPickledSig(clazz: Class[_]) extends Error("Failed to parse pickled Scala signature from: %s".format(clazz))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package rules
package scalasig

import ClassFileParser.{ConstValueIndex, Annotation}
import scala.reflect.generic.ByteCodecs
import scala.reflect.internal.pickling.ByteCodecs

object ScalaSigParser {

Expand Down
Loading