Uh oh!
There was an error while loading. Please reload this page.
fix: get theUnsafe by reflection - #1228
Conversation
Signed-off-by: tison <wander4096@gmail.com>
| if (modules == null) { | ||
| return; | ||
| } | ||
| final Unsafe unsafe = Unsafe.getUnsafe(); |
There was a problem hiding this comment.
Otherwise it will cause a failed privilege check:
@CallerSensitivepublicstaticUnsafegetUnsafe() {
Class<?> caller = Reflection.getCallerClass();
if (!VM.isSystemDomainLoader(caller.getClassLoader()))
thrownewSecurityException("Unsafe");
returntheUnsafe;
}@LazyStone you may try this patch locally and help verify by:
gh repo clone diffplug/spotless
gh pr checkout 1228
./gradlew publishToMavenLocal -x test -Dorg.gradle.jvmargs="--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
buildscript {
repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
}
dependencies {
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.7.0-SNAPSHOT'
}
}
subprojects {
apply plugin: 'com.diffplug.spotless'
}I'm sorry that I miss this local commit at #1224 :( |
nedtwigg
commented
Jun 6, 2022
Out of curiosity, what git client do you use? |
@nedtwigg I use bare You may notice that the fix is done about half an hour after the last previous commit: |
nedtwigg
commented
Jun 6, 2022
No big deal. I am frustrated at the faulty attestation / did not push combo, but I am wayyyyyy more grateful for the very good fix. Thanks very much for contributing, you are wayyyy in the positive sum contribution to the project. You should feel good, not bad! But I guessed that you were a bare CLI user. Everyone I've worked with in person who is committed to the bare CLI is unreliable about whether they pushed what they thought they pushed or not. Shameless plug for the free DiffPlug git client, but you should definitely use some graphical client or another. I haven't yet worked with someone who can be reliable without one. I'll verify locally and push this out later this week. |
tisonkun
commented
Jun 6, 2022
Thanks for your suggestion! I'll try to adopt one :) |
andrej-urvantsev
commented
Jun 6, 2022
@tisonkun it worked! If somebody wants to test this using kotlin DSL: buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.7.0-SNAPSHOT")
}
}
apply(plugin ="com.diffplug.spotless")and instead of spotless {
//...
}I had to use configure<SpotlessExtension> {
java {
// https://github.com/google/google-java-format/releases/latest
googleJavaFormat("1.15.0")
}
} |
tisonkun
commented
Jun 9, 2022
@LazyStone thanks for your verification. ping @nedtwigg as a reminder :) |
nedtwigg
commented
Jun 10, 2022
Published in |
Required for compatibility with JDK 17+. See: diffplug/spotless#1228
This is a follow-up to #1224. Refer to #834.
I'm sorry that I don't push this commit at the first place :(
cc @nedtwigg