File tree Expand file tree Collapse file tree 1 file changed +2
-22
lines changed
lib/src/main/java/com/diffplug/spotless Expand file tree Collapse file tree 1 file changed +2
-22
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2016-2022 DiffPlug
2
+ * Copyright 2016-2023 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
24
24
import java .security .ProtectionDomain ;
25
25
import java .util .Objects ;
26
26
27
- import javax .annotation .Nullable ;
28
-
29
27
/**
30
28
* This class loader is used to load classes of Spotless features from a search
31
29
* path of URLs.<br/>
@@ -113,25 +111,7 @@ private static ByteBuffer urlToByteBuffer(URL url) throws IOException {
113
111
return ByteBuffer .wrap (buffer .toByteArray ());
114
112
}
115
113
116
- /**
117
- * Making spotless Java 9+ compatible. In Java 8 (and minor) the bootstrap
118
- * class loader saw every platform class. In Java 9+ it was changed so the
119
- * bootstrap class loader does not see all classes anymore. This might lead
120
- * to ClassNotFoundException in formatters (e.g. freshmark).
121
- *
122
- * @return <code>null</code> on Java 8 (and minor), otherwise <code>PlatformClassLoader</code>
123
- */
124
- @ Nullable
125
114
private static ClassLoader getParentClassLoader () {
126
- double version = Double .parseDouble (System .getProperty ("java.specification.version" ));
127
- if (version > 1.8 ) {
128
- try {
129
- return (ClassLoader ) ClassLoader .class .getMethod ("getPlatformClassLoader" ).invoke (null );
130
- } catch (Exception e ) {
131
- throw ThrowingEx .asRuntime (e );
132
- }
133
- } else {
134
- return null ;
135
- }
115
+ return ThrowingEx .get (() -> (ClassLoader ) ClassLoader .class .getMethod ("getPlatformClassLoader" ).invoke (null ));
136
116
}
137
117
}
You can’t perform that action at this time.
0 commit comments