[*] Fix non-Java-8 APIs
This commit is contained in:
@@ -11,8 +11,8 @@ group = rootProject.group
|
|||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.toVersion(libs.versions.java.main.get())
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.toVersion(libs.versions.java.main.get())
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -54,8 +54,8 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.compileTestJava {
|
tasks.compileTestJava {
|
||||||
sourceCompatibility = libs.versions.java.test.get()
|
sourceCompatibility = JavaVersion.VERSION_21.toString()
|
||||||
targetCompatibility = libs.versions.java.test.get()
|
targetCompatibility = JavaVersion.VERSION_21.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ assertj = "3.26.3"
|
|||||||
asm = "9.7"
|
asm = "9.7"
|
||||||
autoservice = "1.1.1"
|
autoservice = "1.1.1"
|
||||||
acl = "1.3.5"
|
acl = "1.3.5"
|
||||||
java-main = "8"
|
|
||||||
java-test = "21"
|
|
||||||
jetbrains-annotations = "26.0.1"
|
jetbrains-annotations = "26.0.1"
|
||||||
jspecify = "1.0.0"
|
jspecify = "1.0.0"
|
||||||
junit = "5.12.0"
|
junit = "5.12.0"
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
|
|
||||||
MethodHandle constructorHandle = MethodHandles.lookup().findConstructor(
|
MethodHandle constructorHandle = MethodHandles.lookup().findConstructor(
|
||||||
generatedClass,
|
generatedClass,
|
||||||
MethodType.methodType(void.class, repeatableClass.arrayType())
|
MethodType.methodType(void.class, arrayType(repeatableClass))
|
||||||
);
|
);
|
||||||
|
|
||||||
return (repeatedValues) -> {
|
return (repeatedValues) -> {
|
||||||
@@ -119,9 +119,9 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
"java/lang/Object",
|
"java/lang/Object",
|
||||||
new String[]{containerClass.getName().replace('.', '/')}
|
new String[]{containerClass.getName().replace('.', '/')}
|
||||||
);
|
);
|
||||||
Class<?> repeatableArrayClass = repeatableClass.arrayType();
|
Class<?> repeatableArrayClass = arrayType(repeatableClass);
|
||||||
|
|
||||||
classWriter.visitField(Opcodes.ACC_PRIVATE, "values", repeatableArrayClass.descriptorString(), null, null);
|
classWriter.visitField(Opcodes.ACC_PRIVATE, "values", descriptor(repeatableArrayClass), null, null);
|
||||||
|
|
||||||
appendConstructor(classWriter, repeatableArrayClass, generatedClassNameInternal);
|
appendConstructor(classWriter, repeatableArrayClass, generatedClassNameInternal);
|
||||||
appendValueMethod(classWriter, repeatableArrayClass, generatedClassNameInternal);
|
appendValueMethod(classWriter, repeatableArrayClass, generatedClassNameInternal);
|
||||||
@@ -143,7 +143,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
MethodVisitor methodWriter = classWriter.visitMethod(
|
MethodVisitor methodWriter = classWriter.visitMethod(
|
||||||
Opcodes.ACC_PUBLIC,
|
Opcodes.ACC_PUBLIC,
|
||||||
"<init>",
|
"<init>",
|
||||||
"(" + repeatableArrayClass.descriptorString() + ")V",
|
"(" + descriptor(repeatableArrayClass) + ")V",
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
@@ -157,7 +157,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
Opcodes.PUTFIELD,
|
Opcodes.PUTFIELD,
|
||||||
generatedClassNameInternal,
|
generatedClassNameInternal,
|
||||||
"values",
|
"values",
|
||||||
repeatableArrayClass.descriptorString()
|
descriptor(repeatableArrayClass)
|
||||||
);
|
);
|
||||||
methodWriter.visitInsn(Opcodes.RETURN);
|
methodWriter.visitInsn(Opcodes.RETURN);
|
||||||
methodWriter.visitMaxs(2, 2);
|
methodWriter.visitMaxs(2, 2);
|
||||||
@@ -172,7 +172,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
MethodVisitor methodWriter = classWriter.visitMethod(
|
MethodVisitor methodWriter = classWriter.visitMethod(
|
||||||
Opcodes.ACC_PUBLIC,
|
Opcodes.ACC_PUBLIC,
|
||||||
"value",
|
"value",
|
||||||
"()" + repeatableArrayClass.descriptorString(),
|
"()" + descriptor(repeatableArrayClass),
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
@@ -182,7 +182,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
Opcodes.GETFIELD,
|
Opcodes.GETFIELD,
|
||||||
generatedClassNameInternal,
|
generatedClassNameInternal,
|
||||||
"values",
|
"values",
|
||||||
repeatableArrayClass.descriptorString()
|
descriptor(repeatableArrayClass)
|
||||||
);
|
);
|
||||||
methodWriter.visitInsn(Opcodes.ARETURN);
|
methodWriter.visitInsn(Opcodes.ARETURN);
|
||||||
methodWriter.visitMaxs(1, 1);
|
methodWriter.visitMaxs(1, 1);
|
||||||
@@ -216,14 +216,14 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
Opcodes.GETFIELD,
|
Opcodes.GETFIELD,
|
||||||
generatedClassNameInternal,
|
generatedClassNameInternal,
|
||||||
"values",
|
"values",
|
||||||
repeatableArrayClass.descriptorString()
|
descriptor(repeatableArrayClass)
|
||||||
);
|
);
|
||||||
methodWriter.visitVarInsn(Opcodes.ALOAD, 1);
|
methodWriter.visitVarInsn(Opcodes.ALOAD, 1);
|
||||||
methodWriter.visitMethodInsn(
|
methodWriter.visitMethodInsn(
|
||||||
Opcodes.INVOKEINTERFACE,
|
Opcodes.INVOKEINTERFACE,
|
||||||
containerAnnotationClassBinaryName,
|
containerAnnotationClassBinaryName,
|
||||||
"value",
|
"value",
|
||||||
"()" + repeatableArrayClass.descriptorString(),
|
"()" + descriptor(repeatableArrayClass),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
methodWriter.visitMethodInsn(
|
methodWriter.visitMethodInsn(
|
||||||
@@ -263,7 +263,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
Opcodes.GETFIELD,
|
Opcodes.GETFIELD,
|
||||||
generatedClassNameInternal,
|
generatedClassNameInternal,
|
||||||
"values",
|
"values",
|
||||||
repeatableArrayClass.descriptorString()
|
descriptor(repeatableArrayClass)
|
||||||
);
|
);
|
||||||
methodWriter.visitMethodInsn(
|
methodWriter.visitMethodInsn(
|
||||||
Opcodes.INVOKESTATIC,
|
Opcodes.INVOKESTATIC,
|
||||||
@@ -302,7 +302,7 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
Opcodes.GETFIELD,
|
Opcodes.GETFIELD,
|
||||||
generatedClassNameInternal,
|
generatedClassNameInternal,
|
||||||
"values",
|
"values",
|
||||||
repeatableArrayClass.descriptorString()
|
descriptor(repeatableArrayClass)
|
||||||
);
|
);
|
||||||
methodWriter.visitMethodInsn(
|
methodWriter.visitMethodInsn(
|
||||||
Opcodes.INVOKESTATIC,
|
Opcodes.INVOKESTATIC,
|
||||||
@@ -384,4 +384,17 @@ public class RepeatableAnnotationContainerHelper {
|
|||||||
methodWriter.visitMaxs(1, 1);
|
methodWriter.visitMaxs(1, 1);
|
||||||
methodWriter.visitEnd();
|
methodWriter.visitEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String descriptor(Class<?> clazz) {
|
||||||
|
return Type.getType(clazz).getDescriptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> Class<T[]> arrayType(Class<T> clazz) {
|
||||||
|
try {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (Class<T[]>) Class.forName("[L" + clazz.getName() + ";");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new IllegalStateException("Failed to get array class for " + clazz.getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,9 @@ public class AcyclicGraphSorter {
|
|||||||
while (outgoingIter.hasNext()) {
|
while (outgoingIter.hasNext()) {
|
||||||
if (outgoingIter.next()) {
|
if (outgoingIter.next()) {
|
||||||
if (stack.contains(outgoingIter.index())) {
|
if (stack.contains(outgoingIter.index())) {
|
||||||
throw new GraphCycleException(stack.reversed());
|
Collection<Integer> reversed = new ArrayList<>(stack.size());
|
||||||
|
stack.descendingIterator().forEachRemaining(reversed::add);
|
||||||
|
throw new GraphCycleException(reversed);
|
||||||
}
|
}
|
||||||
stack.push(outgoingIter.index());
|
stack.push(outgoingIter.index());
|
||||||
continue outer;
|
continue outer;
|
||||||
@@ -229,7 +231,9 @@ public class AcyclicGraphSorter {
|
|||||||
int leftBitCount = bitCount;
|
int leftBitCount = bitCount;
|
||||||
if (words == null) {
|
if (words == null) {
|
||||||
for (int i = 0; i < wordCount; i++) {
|
for (int i = 0; i < wordCount; i++) {
|
||||||
sb.repeat("0", Math.min(WORD_SIZE, leftBitCount));
|
for (int j = 0; j < Math.min(WORD_SIZE, leftBitCount); j++) {
|
||||||
|
sb.append("0");
|
||||||
|
}
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
leftBitCount -= WORD_SIZE;
|
leftBitCount -= WORD_SIZE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public abstract class AnnotationRepeatType {
|
|||||||
valueHandle = MethodHandles.lookup().findVirtual(
|
valueHandle = MethodHandles.lookup().findVirtual(
|
||||||
annotationClass(),
|
annotationClass(),
|
||||||
"value",
|
"value",
|
||||||
MethodType.methodType(elementAnnotationClass.arrayType())
|
MethodType.methodType(Class.forName("[L" + elementAnnotationClass.getName() + ";"))
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|||||||
Reference in New Issue
Block a user