Skip to content

Commit 984dc1d

Browse files
committed
Allow package-private main classes to be used with Devtools
Fixes gh-35858
1 parent ad0ce41 commit 984dc1d

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

spring-boot-project/spring-boot-devtools/src/intTest/java/com/example/DevToolsTestApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.springframework.boot.web.context.WebServerPortFileWriter;
2222

2323
@SpringBootApplication
24-
public class DevToolsTestApplication {
24+
class DevToolsTestApplication {
2525

2626
public static void main(String[] args) {
2727
new SpringApplicationBuilder(DevToolsTestApplication.class).listeners(new WebServerPortFileWriter(args[0]))

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartLauncher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ public void run() {
4646
try {
4747
Class<?> mainClass = Class.forName(this.mainClassName, false, getContextClassLoader());
4848
Method mainMethod = mainClass.getDeclaredMethod("main", String[].class);
49+
mainMethod.setAccessible(true);
4950
mainMethod.invoke(null, new Object[] { this.args });
5051
}
5152
catch (Throwable ex) {

src/checkstyle/checkstyle-suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<suppress files="DeprecatedElasticsearchRestClientProperties\.java" checks="SpringMethodVisibility" />
6060
<suppress files="DeprecatedElasticsearchRestClientProperties\.java" checks="SpringMethodVisibility" />
6161
<suppress files="DeprecatedReactiveElasticsearchRestClientProperties\.java" checks="SpringMethodVisibility" />
62+
<suppress files="DevToolsTestApplication\.java" checks="SpringMethodVisibility" />
6263
<suppress files="DevToolsR2dbcAutoConfigurationTests" checks="HideUtilityClassConstructor" />
6364
<suppress files="AbstractLaunchScriptIntegrationTests" checks="IllegalImport" />
6465
<suppress files="SpringBootVersion" checks="JavadocPackage" />

0 commit comments

Comments
 (0)