Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e044817f
Commit
e044817f
authored
Jan 23, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate remaining use of ClassLoader.loadClass to Class.forName
Closes gh-19824
parent
820c671d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
12 deletions
+13
-12
DependencyCustomizer.java
...ringframework/boot/cli/compiler/DependencyCustomizer.java
+3
-3
RestartLauncher.java
...pringframework/boot/devtools/restart/RestartLauncher.java
+2
-2
RestartClassLoader.java
...boot/devtools/restart/classloader/RestartClassLoader.java
+2
-2
MainMethodRunner.java
...ava/org/springframework/boot/loader/MainMethodRunner.java
+1
-1
ModifiedClassPathClassLoader.java
...t/testsupport/classpath/ModifiedClassPathClassLoader.java
+2
-2
NoSuchMethodFailureAnalyzer.java
...oot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java
+3
-2
No files found.
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java
View file @
e044817f
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -93,7 +93,7 @@ public class DependencyCustomizer {
protected
boolean
canAdd
()
{
for
(
String
className
:
classNames
)
{
try
{
DependencyCustomizer
.
this
.
loader
.
loadClass
(
className
);
Class
.
forName
(
className
,
false
,
DependencyCustomizer
.
this
.
loader
);
}
catch
(
Exception
ex
)
{
return
true
;
...
...
@@ -116,7 +116,7 @@ public class DependencyCustomizer {
protected
boolean
canAdd
()
{
for
(
String
className
:
classNames
)
{
try
{
DependencyCustomizer
.
this
.
loader
.
loadClass
(
className
);
Class
.
forName
(
className
,
false
,
DependencyCustomizer
.
this
.
loader
);
return
false
;
}
catch
(
Exception
ex
)
{
...
...
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartLauncher.java
View file @
e044817f
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -44,7 +44,7 @@ class RestartLauncher extends Thread {
@Override
public
void
run
()
{
try
{
Class
<?>
mainClass
=
getContextClassLoader
().
loadClass
(
this
.
mainClassName
);
Class
<?>
mainClass
=
Class
.
forName
(
this
.
mainClassName
,
false
,
getContextClassLoader
()
);
Method
mainMethod
=
mainClass
.
getDeclaredMethod
(
"main"
,
String
[].
class
);
mainMethod
.
invoke
(
null
,
new
Object
[]
{
this
.
args
});
}
...
...
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java
View file @
e044817f
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -141,7 +141,7 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad
loadedClass
=
findClass
(
name
);
}
catch
(
ClassNotFoundException
ex
)
{
loadedClass
=
getParent
().
loadClass
(
name
);
loadedClass
=
Class
.
forName
(
name
,
false
,
getParent
()
);
}
}
if
(
resolve
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java
View file @
e044817f
...
...
@@ -43,7 +43,7 @@ public class MainMethodRunner {
}
public
void
run
()
throws
Exception
{
Class
<?>
mainClass
=
Thread
.
currentThread
().
getContextClassLoader
().
loadClass
(
this
.
mainClassName
);
Class
<?>
mainClass
=
Class
.
forName
(
this
.
mainClassName
,
false
,
Thread
.
currentThread
().
getContextClassLoader
()
);
Method
mainMethod
=
mainClass
.
getDeclaredMethod
(
"main"
,
String
[].
class
);
mainMethod
.
setAccessible
(
true
);
mainMethod
.
invoke
(
null
,
new
Object
[]
{
this
.
args
});
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java
View file @
e044817f
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -76,7 +76,7 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
@Override
public
Class
<?>
loadClass
(
String
name
)
throws
ClassNotFoundException
{
if
(
name
.
startsWith
(
"org.junit"
)
||
name
.
startsWith
(
"org.hamcrest"
))
{
return
this
.
junitLoader
.
loadClass
(
name
);
return
Class
.
forName
(
name
,
false
,
this
.
junitLoader
);
}
return
super
.
loadClass
(
name
);
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzer.java
View file @
e044817f
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -106,7 +106,8 @@ class NoSuchMethodFailureAnalyzer extends AbstractFailureAnalyzer<NoSuchMethodEr
private
URL
getActual
(
String
className
)
{
try
{
return
getClass
().
getClassLoader
().
loadClass
(
className
).
getProtectionDomain
().
getCodeSource
().
getLocation
();
return
Class
.
forName
(
className
,
false
,
getClass
().
getClassLoader
()).
getProtectionDomain
().
getCodeSource
()
.
getLocation
();
}
catch
(
Throwable
ex
)
{
return
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment