-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: get theUnsafe by reflection #1228
Conversation
Signed-off-by: tison <wander4096@gmail.com>
@@ -102,7 +102,9 @@ private static void openPackages(Collection<String> packagesToOpen) throws Throw | |||
if (modules == null) { | |||
return; | |||
} | |||
final Unsafe unsafe = Unsafe.getUnsafe(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise it will cause a failed privilege check:
@CallerSensitive
public static Unsafe getUnsafe() {
Class<?> caller = Reflection.getCallerClass();
if (!VM.isSystemDomainLoader(caller.getClassLoader()))
throw new SecurityException("Unsafe");
return theUnsafe;
}
@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 :( |
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:
|
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. |
Thanks for your suggestion! I'll try to adopt one :) |
@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")
}
} |
@lazystone thanks for your verification. ping @nedtwigg as a reminder :) |
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