Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
jdk: [11, 15]
jdk: [11, 15, 16]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2.1.4
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id("java")
id("java-library")
id("maven-publish")
id("dev.minco.gradle.defaults-plugin") version "0.2.8"
id("dev.minco.gradle.defaults-plugin") version "0.2.26"
id("org.shipkit.shipkit-auto-version") version "1.1.1"
id("org.shipkit.shipkit-changelog") version "1.1.4"
id("org.shipkit.shipkit-github-release") version "1.1.4"
Expand Down
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# The exports are needed due to https://github.com/diffplug/spotless/issues/834
org.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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import lombok.SneakyThrows;

public final class DefineClass {
private static final MethodHandles.Lookup $L = UnsafeAccess.IMPL_LOOKUP;
private static final MethodHandles.Lookup $L = LookupAccess.privateLookupFor(ClassLoader.class);
private static final ProtectionDomain PROTECTION_DOMAIN = AccessController.doPrivileged((PrivilegedAction<ProtectionDomain>) DefineClass.class::getProtectionDomain);
private static final MethodHandle defineClassHandle = getDefineClassHandle();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.minco.javatransformer.internal.util;

import java.lang.invoke.MethodHandles;

import lombok.SneakyThrows;
import lombok.val;

public class LookupAccess {
private static final MethodHandles.Lookup IMPL_LOOKUP;

@SneakyThrows
public static MethodHandles.Lookup privateLookupFor(Class<?> clazz) {
if (IMPL_LOOKUP != null) {
return IMPL_LOOKUP;
}

MethodHandles.Lookup lookup = MethodHandles.lookup();

Object privateLookupIn = MethodHandles.class.getMethod("privateLookupIn", Class.class, MethodHandles.Lookup.class)
.invoke(null, clazz, lookup);
return (MethodHandles.Lookup) privateLookupIn;
}

static {
MethodHandles.Lookup lookup = null;
try {
val field = MethodHandles.Lookup.class.getDeclaredField("IMPL_LOOKUP");
field.setAccessible(true);
lookup = (MethodHandles.Lookup) field.get(null);
} catch (Throwable t) {
System.err.println("Failed to get MethodHandles.Lookup.IMPL_LOOKUP");
t.printStackTrace();
}
IMPL_LOOKUP = lookup;
}
}

This file was deleted.

This file was deleted.