Skip to content

Commit

Permalink
Merge pull request #427 from AVSystem/jdk17
Browse files Browse the repository at this point in the history
JDK17 compatibility
  • Loading branch information
Roman Janusz authored Dec 16, 2022
2 parents d1f2c74 + d930c98 commit e2bbf45
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.13.10, 2.12.17]
java: [graalvm-ce-java11@21.1.0]
java: [graalvm-ce-java11@21.1.0, openjdk@1.17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class SimpleApi {
}

class ApiReflectionTest extends AnyFunSuite {
test("String API") {
test("String API JDK11") {
assume(System.getProperty("java.specification.version") == "11")
assert(ApiInfo.materialize[String].repr ==
"""String {
| def length(): Int
Expand Down Expand Up @@ -140,6 +141,79 @@ class ApiReflectionTest extends AnyFunSuite {
)
}

test("String API JDK17") {
assume(System.getProperty("java.specification.version") == "17")
assert(ApiInfo.materialize[String].repr ==
"""String {
| def length(): Int
| def isEmpty(): Boolean
| def charAt(x$1: Int): Char
| def codePointAt(x$1: Int): Int
| def codePointBefore(x$1: Int): Int
| def codePointCount(x$1: Int, x$2: Int): Int
| def offsetByCodePoints(x$1: Int, x$2: Int): Int
| def getChars(x$1: Int, x$2: Int, x$3: Array[Char], x$4: Int): Unit
| def getBytes(x$1: Int, x$2: Int, x$3: Array[Byte], x$4: Int): Unit
| def getBytes(x$1: String): Array[Byte]
| def getBytes(x$1: java.nio.charset.Charset): Array[Byte]
| def getBytes(): Array[Byte]
| def contentEquals(x$1: StringBuffer): Boolean
| def contentEquals(x$1: CharSequence): Boolean
| def equalsIgnoreCase(x$1: String): Boolean
| def compareTo(x$1: String): Int
| def compareToIgnoreCase(x$1: String): Int
| def regionMatches(x$1: Int, x$2: String, x$3: Int, x$4: Int): Boolean
| def regionMatches(x$1: Boolean, x$2: Int, x$3: String, x$4: Int, x$5: Int): Boolean
| def startsWith(x$1: String, x$2: Int): Boolean
| def startsWith(x$1: String): Boolean
| def endsWith(x$1: String): Boolean
| def indexOf(x$1: Int): Int
| def indexOf(x$1: Int, x$2: Int): Int
| def lastIndexOf(x$1: Int): Int
| def lastIndexOf(x$1: Int, x$2: Int): Int
| def indexOf(x$1: String): Int
| def indexOf(x$1: String, x$2: Int): Int
| def lastIndexOf(x$1: String): Int
| def lastIndexOf(x$1: String, x$2: Int): Int
| def substring(x$1: Int): String
| def substring(x$1: Int, x$2: Int): String
| def subSequence(x$1: Int, x$2: Int): CharSequence
| def concat(x$1: String): String
| def replace(x$1: Char, x$2: Char): String
| def matches(x$1: String): Boolean
| def contains(x$1: CharSequence): Boolean
| def replaceFirst(x$1: String, x$2: String): String
| def replaceAll(x$1: String, x$2: String): String
| def replace(x$1: CharSequence, x$2: CharSequence): String
| def split(x$1: String, x$2: Int): Array[String]
| def split(x$1: String): Array[String]
| def toLowerCase(x$1: java.util.Locale): String
| def toLowerCase(): String
| def toUpperCase(x$1: java.util.Locale): String
| def toUpperCase(): String
| def trim(): String
| def strip(): String
| def stripLeading(): String
| def stripTrailing(): String
| def isBlank(): Boolean
| def lines(): java.util.stream.Stream[String]
| def indent(x$1: Int): String
| def stripIndent(): String
| def translateEscapes(): String
| def transform[R](x$1: java.util.function.Function[_ >: String, _ <: R]): R
| def chars(): java.util.stream.IntStream
| def codePoints(): java.util.stream.IntStream
| def toCharArray(): Array[Char]
| def formatted(x$1: Seq[AnyRef]): String
| def intern(): String
| def repeat(x$1: Int): String
| def describeConstable(): java.util.Optional[String]
| def resolveConstantDesc(x$1: java.lang.invoke.MethodHandles.Lookup): String
| final def +(x$1: Any): String
|}""".stripMargin
)
}

test("Simple API") {
assert(ApiInfo.materialize[SimpleApi].repr ==
"""com.avsystem.commons.rpc.SimpleApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ trait MacroCommons extends CompatMacroCommons { bundle =>
actualParamType(param.typeSignature)

def actualParamType(tpe: Type): Type = tpe match {
case TypeRef(_, s, List(arg)) if s == definitions.RepeatedParamClass =>
case TypeRef(_, s, List(arg)) if s == definitions.RepeatedParamClass || s == definitions.JavaRepeatedParamClass =>
getType(tq"$ScalaPkg.Seq[$arg]")
case TypeRef(_, s, List(arg)) if s == definitions.ByNameParamClass =>
arg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ object XEntryId {
CommandArg((enc, eid) => enc.add(eid.toString))
}

case class XEntry[Record](id: XEntryId, data: Record)
case class XEntry[Rec](id: XEntryId, data: Rec)

case class XMaxlen(maxlen: Long, approx: Boolean = true)
object XMaxlen {
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object Build extends BuildDef {
githubWorkflowEnv ++= Map(
"REDIS_VERSION" -> "6.2.6",
),
githubWorkflowJavaVersions := Seq("graalvm-ce-java11@21.1.0"),
githubWorkflowJavaVersions := Seq("graalvm-ce-java11@21.1.0", "openjdk@1.17"),
githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
"actions", "cache", "v2",
Expand Down

0 comments on commit e2bbf45

Please sign in to comment.