Skip to content

Commit ba694b8

Browse files
committed
Upgrade codebase to Java 21
1 parent a84ce73 commit ba694b8

8 files changed

Lines changed: 18 additions & 26 deletions

File tree

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ dependencies {
6464
jvmdg {
6565
downgradeTo = JavaVersion.VERSION_1_8
6666
multiReleaseOriginal.set(true)
67-
multiReleaseVersions = [JavaVersion.VERSION_17]
67+
multiReleaseVersions = [JavaVersion.VERSION_17, JavaVersion.VERSION_21]
6868
}
6969

7070
base {
@@ -84,7 +84,7 @@ processResources {
8484
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
8585
tasks.withType(JavaCompile).configureEach {
8686
it.options.encoding = "UTF-8"
87-
it.options.release = 17
87+
it.options.release = 21
8888
}
8989

9090
java {
@@ -93,8 +93,8 @@ java {
9393
// If you remove this line, sources will not be generated.
9494
withSourcesJar()
9595

96-
sourceCompatibility = JavaVersion.VERSION_17
97-
targetCompatibility = JavaVersion.VERSION_17
96+
sourceCompatibility = JavaVersion.VERSION_21
97+
targetCompatibility = JavaVersion.VERSION_21
9898
}
9999

100100
shadowJar {

src/main/java/fr/catcore/modremapperapi/utils/MixinUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ public static void applyASMMagic(String targetClassName, ClassNode targetClass,
138138
private static void transformCalls(ClassNode classNode, Consumer<MethodInsnNode> consumer) {
139139
for (MethodNode method : classNode.methods) {
140140
for (AbstractInsnNode insn : method.instructions) {
141-
if (insn instanceof MethodInsnNode) {
142-
MethodInsnNode call = (MethodInsnNode) insn;
141+
if (insn instanceof MethodInsnNode call) {
143142
consumer.accept(call);
144143
}
145144
}

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/ModRemappingAPIImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void init() {
5151
var v2Keys = new ArrayList<>(v2Remappers.keySet());
5252

5353
while (!v2Keys.isEmpty()) {
54-
var contextKey = v2Keys.remove(0);
54+
var contextKey = v2Keys.removeFirst();
5555
var context = new ModRemmaperV2Context(contextKey, v2Remappers.get(contextKey));
5656
CURRENT_CONTEXT = context;
5757

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/mappings/MappingsRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void gatherChildClassCandidates(TrEnvironment trEnvironment, Map<Extende
209209
var toAdd = new ArrayList<>(entry.getValue());
210210

211211
while (!toAdd.isEmpty()) {
212-
var trClass = trEnvironment.getClass(toAdd.remove(0));
212+
var trClass = trEnvironment.getClass(toAdd.removeFirst());
213213
if (trClass == null) continue;
214214

215215
var children = trClass.getChildren().stream()

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/remapper/SoftLockFixer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.net.URL;
1010
import java.net.URLConnection;
1111
import java.util.ArrayList;
12-
import java.util.Arrays;
1312
import java.util.List;
1413
import java.util.stream.Stream;
1514

@@ -35,15 +34,15 @@ public static void preloadClasses() {
3534
}
3635
}
3736

38-
Stream<String> t = classes.stream().flatMap(s -> s);
39-
List<String> toCheck = new ArrayList<>(Arrays.asList(new String[] {
37+
var t = classes.stream().flatMap(s -> s);
38+
var toCheck = new ArrayList<>(List.of(
4039
"net.fabricmc.loader.impl.launch.FabricLauncher",
4140
"net.fabricmc.loader.impl.launch.FabricLauncherBase",
4241
"net.fabricmc.loader.api.ObjectShare",
4342
"javax.lang.model.SourceVersion",
4443
getLibClassName("tinyremapper", "extension.mixin.hard.ImprovedHardTargetMixinClassVisitor"),
4544
getLibClassName("tinyremapper", "extension.mixin.hard.ImprovedMixinAnnotationVisitor")
46-
}));
45+
));
4746
toCheck.addAll(t.toList());
4847

4948
for (String clazz : toCheck) {

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/remapper/minecraft/ClasspathUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ public static Set<Path> getRemapClasspath() throws IOException {
4949

5050
completeClasspath.addAll(classPaths);
5151

52-
Optional.ofNullable(share.get("fabric-loader:inputRealmsJar"))
53-
.filter(Path.class::isInstance)
54-
.map(Path.class::cast)
55-
.ifPresent(completeClasspath::add);
52+
if (share.get("fabric-loader:inputRealmsJar") instanceof Path realmsJar) {
53+
completeClasspath.add(realmsJar);
54+
}
5655

5756
return completeClasspath;
5857
}

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/remapper/visitor/MixinPostApplyVisitorProvider.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ public ClassVisitor insertApplyVisitor(TrClass cls, ClassVisitor next) {
4040

4141
if (value instanceof List<?> valueList) {
4242
for (Object val : valueList) {
43-
String theVal;
44-
45-
if (val instanceof Type type) {
46-
theVal = type.getInternalName();
47-
} else {
48-
theVal = ModRemappingAPIImpl.getCurrentContext().getMixinData().getMixinRefmapData()
43+
supers.add(switch (val) {
44+
case Type type -> type.getInternalName();
45+
default -> ModRemappingAPIImpl.getCurrentContext().getMixinData().getMixinRefmapData()
4946
.getOrDefault(className, new HashMap<>()).getOrDefault((String) val, (String) val);
50-
}
51-
52-
supers.add(theVal);
47+
});
5348
}
5449
}
5550
}

src/main/java/io/github/fabriccompatibilitylayers/modremappingapi/impl/utils/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void delete(Collection<Path> paths) {
4141

4242
@ApiStatus.Internal
4343
public static void downloadFile(String url, Path target) throws IOException {
44-
try (var inputStream = new BufferedInputStream(new URL(url).openStream());
44+
try (var inputStream = new BufferedInputStream(URI.create(url).toURL().openStream());
4545
var outputStream = new BufferedOutputStream(Files.newOutputStream(target))) {
4646

4747
var buffer = new byte[2048];

0 commit comments

Comments
 (0)