From 2c8a4d3a62a174ee42e4cb7e577ff9e0d795d927 Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Tue, 25 Jan 2022 14:23:02 +0900 Subject: [PATCH] avoid deprecated `java.lang.Class.newInstance` https://app.travis-ci.com/github/playframework/twirl/jobs/554186867#L356 ``` [warn] /home/travis/build/playframework/twirl/parser/src/main/scala/play/twirl/parser/TwirlParser.scala:334:76: method newInstance in class Class is deprecated [warn] val ab = if (provided != null) provided else manifest.runtimeClass.newInstance().asInstanceOf[BufferType] [warn] ^ [info] done compiling ``` --- parser/src/main/scala/play/twirl/parser/TwirlParser.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser/src/main/scala/play/twirl/parser/TwirlParser.scala b/parser/src/main/scala/play/twirl/parser/TwirlParser.scala index 6d9daa1f..b885addc 100644 --- a/parser/src/main/scala/play/twirl/parser/TwirlParser.scala +++ b/parser/src/main/scala/play/twirl/parser/TwirlParser.scala @@ -331,7 +331,8 @@ class TwirlParser(val shouldParseInclusiveDot: Boolean) { def several[T, BufferType <: mutable.Buffer[T]](parser: () => T, provided: BufferType = null)(implicit manifest: Manifest[BufferType] ): BufferType = { - val ab = if (provided != null) provided else manifest.runtimeClass.newInstance().asInstanceOf[BufferType] + val ab = + if (provided != null) provided else manifest.runtimeClass.getConstructor().newInstance().asInstanceOf[BufferType] var parsed = parser() while (parsed != null) { ab += parsed