[*] Fix non-Java-8 APIs
This commit is contained in:
@@ -11,8 +11,8 @@ group = rootProject.group
|
||||
version = rootProject.version
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.toVersion(libs.versions.java.main.get())
|
||||
targetCompatibility = JavaVersion.toVersion(libs.versions.java.main.get())
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -54,8 +54,8 @@ dependencies {
|
||||
}
|
||||
|
||||
tasks.compileTestJava {
|
||||
sourceCompatibility = libs.versions.java.test.get()
|
||||
targetCompatibility = libs.versions.java.test.get()
|
||||
sourceCompatibility = JavaVersion.VERSION_21.toString()
|
||||
targetCompatibility = JavaVersion.VERSION_21.toString()
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
|
||||
@@ -3,8 +3,6 @@ assertj = "3.26.3"
|
||||
asm = "9.7"
|
||||
autoservice = "1.1.1"
|
||||
acl = "1.3.5"
|
||||
java-main = "8"
|
||||
java-test = "21"
|
||||
jetbrains-annotations = "26.0.1"
|
||||
jspecify = "1.0.0"
|
||||
junit = "5.12.0"
|
||||
|
||||
@@ -89,7 +89,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
|
||||
MethodHandle constructorHandle = MethodHandles.lookup().findConstructor(
|
||||
generatedClass,
|
||||
MethodType.methodType(void.class, repeatableClass.arrayType())
|
||||
MethodType.methodType(void.class, arrayType(repeatableClass))
|
||||
);
|
||||
|
||||
return (repeatedValues) -> {
|
||||
@@ -119,9 +119,9 @@ public class RepeatableAnnotationContainerHelper {
|
||||
"java/lang/Object",
|
||||
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);
|
||||
appendValueMethod(classWriter, repeatableArrayClass, generatedClassNameInternal);
|
||||
@@ -143,7 +143,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
MethodVisitor methodWriter = classWriter.visitMethod(
|
||||
Opcodes.ACC_PUBLIC,
|
||||
"<init>",
|
||||
"(" + repeatableArrayClass.descriptorString() + ")V",
|
||||
"(" + descriptor(repeatableArrayClass) + ")V",
|
||||
null,
|
||||
null
|
||||
);
|
||||
@@ -157,7 +157,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
Opcodes.PUTFIELD,
|
||||
generatedClassNameInternal,
|
||||
"values",
|
||||
repeatableArrayClass.descriptorString()
|
||||
descriptor(repeatableArrayClass)
|
||||
);
|
||||
methodWriter.visitInsn(Opcodes.RETURN);
|
||||
methodWriter.visitMaxs(2, 2);
|
||||
@@ -172,7 +172,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
MethodVisitor methodWriter = classWriter.visitMethod(
|
||||
Opcodes.ACC_PUBLIC,
|
||||
"value",
|
||||
"()" + repeatableArrayClass.descriptorString(),
|
||||
"()" + descriptor(repeatableArrayClass),
|
||||
null,
|
||||
null
|
||||
);
|
||||
@@ -182,7 +182,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
Opcodes.GETFIELD,
|
||||
generatedClassNameInternal,
|
||||
"values",
|
||||
repeatableArrayClass.descriptorString()
|
||||
descriptor(repeatableArrayClass)
|
||||
);
|
||||
methodWriter.visitInsn(Opcodes.ARETURN);
|
||||
methodWriter.visitMaxs(1, 1);
|
||||
@@ -216,14 +216,14 @@ public class RepeatableAnnotationContainerHelper {
|
||||
Opcodes.GETFIELD,
|
||||
generatedClassNameInternal,
|
||||
"values",
|
||||
repeatableArrayClass.descriptorString()
|
||||
descriptor(repeatableArrayClass)
|
||||
);
|
||||
methodWriter.visitVarInsn(Opcodes.ALOAD, 1);
|
||||
methodWriter.visitMethodInsn(
|
||||
Opcodes.INVOKEINTERFACE,
|
||||
containerAnnotationClassBinaryName,
|
||||
"value",
|
||||
"()" + repeatableArrayClass.descriptorString(),
|
||||
"()" + descriptor(repeatableArrayClass),
|
||||
true
|
||||
);
|
||||
methodWriter.visitMethodInsn(
|
||||
@@ -263,7 +263,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
Opcodes.GETFIELD,
|
||||
generatedClassNameInternal,
|
||||
"values",
|
||||
repeatableArrayClass.descriptorString()
|
||||
descriptor(repeatableArrayClass)
|
||||
);
|
||||
methodWriter.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
@@ -302,7 +302,7 @@ public class RepeatableAnnotationContainerHelper {
|
||||
Opcodes.GETFIELD,
|
||||
generatedClassNameInternal,
|
||||
"values",
|
||||
repeatableArrayClass.descriptorString()
|
||||
descriptor(repeatableArrayClass)
|
||||
);
|
||||
methodWriter.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
@@ -384,4 +384,17 @@ public class RepeatableAnnotationContainerHelper {
|
||||
methodWriter.visitMaxs(1, 1);
|
||||
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()) {
|
||||
if (outgoingIter.next()) {
|
||||
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());
|
||||
continue outer;
|
||||
@@ -229,7 +231,9 @@ public class AcyclicGraphSorter {
|
||||
int leftBitCount = bitCount;
|
||||
if (words == null) {
|
||||
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(" ");
|
||||
leftBitCount -= WORD_SIZE;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class AnnotationRepeatType {
|
||||
valueHandle = MethodHandles.lookup().findVirtual(
|
||||
annotationClass(),
|
||||
"value",
|
||||
MethodType.methodType(elementAnnotationClass.arrayType())
|
||||
MethodType.methodType(Class.forName("[L" + elementAnnotationClass.getName() + ";"))
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
Reference in New Issue
Block a user