Skip to content

Commit

Permalink
Merge pull request #111 from xuwei-k/Class-newInstance
Browse files Browse the repository at this point in the history
avoid deprecated `Class.newInstance`
  • Loading branch information
eed3si9n authored Oct 15, 2024
2 parents 7399c14 + 900c695 commit 539dd33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ class Launch private[xsbt] (
entryPoint.asSubclass(AppMainClass)
def newMain(): xsbti.AppMain = {
if (ServerApplication.isServerApplication(entryPoint)) ServerApplication(this)
else if (AppMainClass.isAssignableFrom(entryPoint)) mainClass.newInstance
else if (AppMainClass.isAssignableFrom(entryPoint))
mainClass.getDeclaredConstructor().newInstance()
else if (PlainApplication.isPlainApplication(entryPoint)) PlainApplication(entryPoint)
else
throw new IncompatibleClassChangeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class ServerApplication private (provider: xsbti.AppProvider) extends xsbti.AppM
import ServerApplication._

override def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = {
val serverMain = provider.entryPoint.asSubclass(ServerMainClass).newInstance
val serverMain =
provider.entryPoint.asSubclass(ServerMainClass).getDeclaredConstructor().newInstance()
val server = serverMain.start(configuration)
Console.err.println(s"${SERVER_SYNCH_TEXT}${server.uri}")
server.awaitTermination()
Expand Down

0 comments on commit 539dd33

Please sign in to comment.