Skip to content

Commit 539dd33

Browse files
authored
Merge pull request #111 from xuwei-k/Class-newInstance
avoid deprecated `Class.newInstance`
2 parents 7399c14 + 900c695 commit 539dd33

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

launcher-implementation/src/main/scala/xsbt/boot/Launch.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ class Launch private[xsbt] (
493493
entryPoint.asSubclass(AppMainClass)
494494
def newMain(): xsbti.AppMain = {
495495
if (ServerApplication.isServerApplication(entryPoint)) ServerApplication(this)
496-
else if (AppMainClass.isAssignableFrom(entryPoint)) mainClass.newInstance
496+
else if (AppMainClass.isAssignableFrom(entryPoint))
497+
mainClass.getDeclaredConstructor().newInstance()
497498
else if (PlainApplication.isPlainApplication(entryPoint)) PlainApplication(entryPoint)
498499
else
499500
throw new IncompatibleClassChangeError(

launcher-implementation/src/main/scala/xsbt/boot/ServerApplication.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class ServerApplication private (provider: xsbti.AppProvider) extends xsbti.AppM
1212
import ServerApplication._
1313

1414
override def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = {
15-
val serverMain = provider.entryPoint.asSubclass(ServerMainClass).newInstance
15+
val serverMain =
16+
provider.entryPoint.asSubclass(ServerMainClass).getDeclaredConstructor().newInstance()
1617
val server = serverMain.start(configuration)
1718
Console.err.println(s"${SERVER_SYNCH_TEXT}${server.uri}")
1819
server.awaitTermination()

0 commit comments

Comments
 (0)