Skip to content

Commit fa78eff

Browse files
committed
build: Bump to a minimum requirement of Java 17
1 parent 4fe9bdf commit fa78eff

9 files changed

Lines changed: 58 additions & 173 deletions

.teamcity/settings.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ project {
3636
text("github_repository_name", "ForgeFlower", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `ForgeFlower` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
3737
text("env.PUBLISHED_JAVA_ARTIFACT_ID", "forgeflower", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false)
3838
text("env.PUBLISHED_JAVA_GROUP", "net.minecraftforge", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false)
39-
text("docker_jdk_version", "8", label = "JDK version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
40-
text("docker_gradle_version", "7.4", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
39+
text("docker_jdk_version", "17", label = "JDK version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
40+
text("docker_gradle_version", "7.4.1", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
4141
text("env.EMAIL", "ForgeTC@MinecraftForge.net", label = "Git Email", description = "Git email for use in the fake repo", display = ParameterDisplay.HIDDEN, allowEmpty = false)
4242
checkbox(
4343
"should_execute_tests",

FernFlower-Patches/0001-Git-filter-and-setup-backport-to-Java-8.patch

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,34 +2442,3 @@ index f9553162f122c71b34635112e717c3e733b5b212..62bd9b9ccefea2b65ae41e5d9a545e20
24422442

24432443
@rem Find java.exe
24442444
if defined JAVA_HOME goto findJavaFromJavaHome
2445-
diff --git a/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java b/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
2446-
index 3280038cb409ed7f96e99da714dc5127b74fd1ca..1dedf68f53090579fc197d85800b4f7b62d9a1e6 100644
2447-
--- a/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
2448-
+++ b/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
2449-
@@ -213,7 +213,12 @@ public class ConstantPool implements NewClassNameBuilder {
2450-
if (newName != null) {
2451-
StringBuilder buffer = new StringBuilder();
2452-
if (vt.arrayDim > 0) {
2453-
- buffer.append("[".repeat(vt.arrayDim)).append('L').append(newName).append(';');
2454-
+ // No functional change, just a revert for J8 compatibility
2455-
+ for (int i = 0; i < vt.arrayDim; i++) {
2456-
+ buffer.append('[');
2457-
+ }
2458-
+
2459-
+ buffer.append('L').append(newName).append(';');
2460-
}
2461-
else {
2462-
buffer.append(newName);
2463-
diff --git a/src/org/jetbrains/java/decompiler/util/SFormsFastMapDirect.java b/src/org/jetbrains/java/decompiler/util/SFormsFastMapDirect.java
2464-
index bb8b4dd9b866ec54491da50310b09b6fcb0bdf3f..7143281598c9273e847cc8aa5d86178c3b2b6bab 100644
2465-
--- a/src/org/jetbrains/java/decompiler/util/SFormsFastMapDirect.java
2466-
+++ b/src/org/jetbrains/java/decompiler/util/SFormsFastMapDirect.java
2467-
@@ -342,7 +342,7 @@ public class SFormsFastMapDirect {
2468-
if (ent != null) {
2469-
final int key = i == 0 ? ikey : (i == 1 ? ikey + VarExprent.STACK_BASE : -ikey);
2470-
2471-
- list.add(new Entry<>() {
2472-
+ list.add(new Entry<Integer, FastSparseSet<Integer>>() {
2473-
2474-
private final Integer var = key;
2475-
private final FastSparseSet<Integer> val = ent;

FernFlower-Patches/0011-Rework-of-Generics-system-for-better-output.patch

Lines changed: 50 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,93 +4,6 @@ Date: Fri, 14 Apr 2017 17:09:41 -0700
44
Subject: [PATCH] Rework of Generics system for better output
55

66

7-
diff --git a/java9/org/jetbrains/java/decompiler/util/ClasspathScanner.java b/java9/org/jetbrains/java/decompiler/util/ClasspathScanner.java
8-
new file mode 100644
9-
index 0000000000000000000000000000000000000000..ad9f8c22d02565f22720a4fa8819511124598dac
10-
--- /dev/null
11-
+++ b/java9/org/jetbrains/java/decompiler/util/ClasspathScanner.java
12-
@@ -0,0 +1,81 @@
13-
+// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
14-
+package org.jetbrains.java.decompiler.util;
15-
+
16-
+import java.lang.module.*;
17-
+import java.lang.reflect.InvocationTargetException;
18-
+import java.lang.reflect.Method;
19-
+import java.nio.ByteBuffer;
20-
+import java.io.File;
21-
+import java.io.IOException;
22-
+import java.io.InputStream;
23-
+import java.util.HashSet;
24-
+import java.util.Optional;
25-
+import java.util.Set;
26-
+import java.util.stream.Stream;
27-
+
28-
+import org.jetbrains.java.decompiler.main.DecompilerContext;
29-
+import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger.Severity;
30-
+import org.jetbrains.java.decompiler.struct.StructContext;
31-
+
32-
+public class ClasspathScanner {
33-
+
34-
+ public static void addAllClasspath(StructContext ctx) {
35-
+ Set<String> found = new HashSet<String>();
36-
+ String[] props = { System.getProperty("java.class.path"), System.getProperty("sun.boot.class.path") };
37-
+ for (String prop : props) {
38-
+ if (prop == null)
39-
+ continue;
40-
+
41-
+ for (final String path : prop.split(File.pathSeparator)) {
42-
+ File file = new File(path);
43-
+ if (found.contains(file.getAbsolutePath()))
44-
+ continue;
45-
+
46-
+ if (file.exists() && (file.getName().endsWith(".class") || file.getName().endsWith(".jar"))) {
47-
+ DecompilerContext.getLogger().writeMessage("Adding File to context from classpath: " + file, Severity.INFO);
48-
+ ctx.addSpace(file, false);
49-
+ found.add(file.getAbsolutePath());
50-
+ }
51-
+ }
52-
+ }
53-
+
54-
+ addAllModulePath(ctx);
55-
+ }
56-
+
57-
+ private static void addAllModulePath(StructContext ctx) {
58-
+ for (ModuleReference module : ModuleFinder.ofSystem().findAll()) {
59-
+ String name = module.descriptor().name();
60-
+ try {
61-
+ ModuleReader reader = module.open();
62-
+ DecompilerContext.getLogger().writeMessage("Reading Module: " + name, Severity.INFO);
63-
+ reader.list().forEach(cls -> {
64-
+ if (!cls.endsWith(".class") || cls.contains("module-info.class"))
65-
+ return;
66-
+
67-
+ DecompilerContext.getLogger().writeMessage(" " + cls, Severity.INFO);
68-
+ try {
69-
+ Optional<ByteBuffer> bb = reader.read(cls);
70-
+ if (!bb.isPresent()) {
71-
+ DecompilerContext.getLogger().writeMessage(" Error Reading Class: " + cls, Severity.ERROR);
72-
+ return;
73-
+ }
74-
+
75-
+ byte[] data;
76-
+ if (bb.get().hasArray()) {
77-
+ data = bb.get().array();
78-
+ } else {
79-
+ data = new byte[bb.get().remaining()];
80-
+ bb.get().get(data);
81-
+ }
82-
+ ctx.addData(name, cls, data, false);
83-
+ } catch (IOException e) {
84-
+ DecompilerContext.getLogger().writeMessage(" Error Reading Class: " + cls, e);
85-
+ }
86-
+ });
87-
+ reader.close();
88-
+ } catch (IOException e) {
89-
+ DecompilerContext.getLogger().writeMessage("Error loading module " + name, e);
90-
+ }
91-
+ }
92-
+ }
93-
+}
947
diff --git a/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java b/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java
958
index e082267cf9e2f20df662ff3565d69d0966df1126..425c2e4480f2c57993e3d4a38f66cfdcbb920047 100644
969
--- a/src/org/jetbrains/java/decompiler/main/ClassReference14Processor.java
@@ -2496,24 +2409,31 @@ index 8b6105dbbfea358241702acbc691976d51f0d726..4261dce0b37505d22c6e9ee7c3e0bdb7
24962409
}
24972410
diff --git a/src/org/jetbrains/java/decompiler/util/ClasspathScanner.java b/src/org/jetbrains/java/decompiler/util/ClasspathScanner.java
24982411
new file mode 100644
2499-
index 0000000000000000000000000000000000000000..a76571c1359c904bdb1e374bbc1e4969850b8087
2412+
index 0000000000000000000000000000000000000000..ad9f8c22d02565f22720a4fa8819511124598dac
25002413
--- /dev/null
25012414
+++ b/src/org/jetbrains/java/decompiler/util/ClasspathScanner.java
2502-
@@ -0,0 +1,35 @@
2415+
@@ -0,0 +1,81 @@
25032416
+// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
25042417
+package org.jetbrains.java.decompiler.util;
25052418
+
2419+
+import java.lang.module.*;
2420+
+import java.lang.reflect.InvocationTargetException;
2421+
+import java.lang.reflect.Method;
2422+
+import java.nio.ByteBuffer;
25062423
+import java.io.File;
2424+
+import java.io.IOException;
2425+
+import java.io.InputStream;
25072426
+import java.util.HashSet;
2427+
+import java.util.Optional;
25082428
+import java.util.Set;
2429+
+import java.util.stream.Stream;
25092430
+
25102431
+import org.jetbrains.java.decompiler.main.DecompilerContext;
25112432
+import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger.Severity;
25122433
+import org.jetbrains.java.decompiler.struct.StructContext;
25132434
+
25142435
+public class ClasspathScanner {
2515-
+ //TODO: Look into caching the metadata grabbed from the context info?
2516-
+ //J9 destroies the classpath so we need to scan this differently. We take advantage of MultiRelease jars to do this.
2436+
+
25172437
+ public static void addAllClasspath(StructContext ctx) {
25182438
+ Set<String> found = new HashSet<String>();
25192439
+ String[] props = { System.getProperty("java.class.path"), System.getProperty("sun.boot.class.path") };
@@ -2533,6 +2453,45 @@ index 0000000000000000000000000000000000000000..a76571c1359c904bdb1e374bbc1e4969
25332453
+ }
25342454
+ }
25352455
+ }
2456+
+
2457+
+ addAllModulePath(ctx);
2458+
+ }
2459+
+
2460+
+ private static void addAllModulePath(StructContext ctx) {
2461+
+ for (ModuleReference module : ModuleFinder.ofSystem().findAll()) {
2462+
+ String name = module.descriptor().name();
2463+
+ try {
2464+
+ ModuleReader reader = module.open();
2465+
+ DecompilerContext.getLogger().writeMessage("Reading Module: " + name, Severity.INFO);
2466+
+ reader.list().forEach(cls -> {
2467+
+ if (!cls.endsWith(".class") || cls.contains("module-info.class"))
2468+
+ return;
2469+
+
2470+
+ DecompilerContext.getLogger().writeMessage(" " + cls, Severity.INFO);
2471+
+ try {
2472+
+ Optional<ByteBuffer> bb = reader.read(cls);
2473+
+ if (!bb.isPresent()) {
2474+
+ DecompilerContext.getLogger().writeMessage(" Error Reading Class: " + cls, Severity.ERROR);
2475+
+ return;
2476+
+ }
2477+
+
2478+
+ byte[] data;
2479+
+ if (bb.get().hasArray()) {
2480+
+ data = bb.get().array();
2481+
+ } else {
2482+
+ data = new byte[bb.get().remaining()];
2483+
+ bb.get().get(data);
2484+
+ }
2485+
+ ctx.addData(name, cls, data, false);
2486+
+ } catch (IOException e) {
2487+
+ DecompilerContext.getLogger().writeMessage(" Error Reading Class: " + cls, e);
2488+
+ }
2489+
+ });
2490+
+ reader.close();
2491+
+ } catch (IOException e) {
2492+
+ DecompilerContext.getLogger().writeMessage("Error loading module " + name, e);
2493+
+ }
2494+
+ }
25362495
+ }
25372496
+}
25382497
diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java

FernFlower-Patches/0016-Add-better-debug-logging.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ index 36d1d6c4ae8e3b9f1a64dae514d9efa65722033a..7c91206d1b64b9873fa24d6d3ad38e73
5959
classes.put(cl.qualifiedName, cl);
6060
unit.addClass(cl, name);
6161
diff --git a/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java b/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
62-
index 1dedf68f53090579fc197d85800b4f7b62d9a1e6..02736cc932eee86708997bbfa919d2041ddfee21 100644
62+
index 3280038cb409ed7f96e99da714dc5127b74fd1ca..cb772c2f7d1111b8cfde0312951576bd1dc718f1 100644
6363
--- a/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
6464
+++ b/src/org/jetbrains/java/decompiler/struct/consts/ConstantPool.java
6565
@@ -87,6 +87,9 @@ public class ConstantPool implements NewClassNameBuilder {

build.gradle

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,8 @@ project(':ForgeFlower') {
3636
sourcesJar.dependsOn rootProject.tasks.applyPatches
3737
}
3838

39-
project(':ForgeFlower9') {
40-
apply plugin: 'java'
41-
apply plugin: 'eclipse'
42-
43-
sourceSets {
44-
java9.java.srcDirs = ['../ForgeFlower/java9']
45-
}
46-
47-
eclipse {
48-
project {
49-
name 'FernFlower9'
50-
linkedResource name: 'java9', type: '2', location: project(':ForgeFlower').file('java9').getAbsolutePath()
51-
}
52-
}
53-
54-
dependencies {
55-
implementation project(':ForgeFlower')
56-
}
57-
58-
java.toolchain {
59-
languageVersion = JavaLanguageVersion.of(9)
60-
}
61-
}
62-
6339
if (tasks.findByName('eclipse') == null) tasks.create('eclipse')
64-
tasks.findByName('eclipse').dependsOn('applyPatches', 'ForgeFlower:eclipse', 'ForgeFlower9:eclipse')
40+
tasks.findByName('eclipse').dependsOn('applyPatches', 'ForgeFlower:eclipse')
6541

6642
changelog {
6743
fromMergeBase()

fernflower.gradle

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ ext {
1111
sourceSets {
1212
main.java.srcDirs = ['src']
1313
test.java.srcDirs = ['test']
14-
java9.java.srcDirs = ['java9']
1514
}
1615

1716
repositories {
@@ -20,48 +19,31 @@ repositories {
2019
}
2120

2221
dependencies {
23-
// The Java9 code depends on (can see) the "main" source set
24-
java9Implementation sourceSets.main.output
25-
2622
testImplementation 'junit:junit:4.+'
2723
testImplementation 'org.hamcrest:hamcrest-core:1.3'
2824
testImplementation 'org.assertj:assertj-core:3.+'
2925
testImplementation 'com.google.code.gson:gson:2.8.0'
3026
}
3127

28+
// Default all standard Java compile tasks to Java 17
3229
java.toolchain {
33-
languageVersion = JavaLanguageVersion.of(8)
30+
languageVersion = JavaLanguageVersion.of(17)
3431
}
3532

36-
// Default all standard Java compile tasks to Java 8
37-
// We'll specify Java 9 only for the java9 compile task
3833
tasks.withType(JavaCompile) {
3934
options.deprecation = true
4035
}
4136

42-
compileJava9Java {
43-
javaCompiler = javaToolchains.compilerFor {
44-
languageVersion = JavaLanguageVersion.of(9)
45-
}
46-
}
47-
4837
eclipse {
49-
classpath {
50-
sourceSets -= [sourceSets.java9]
51-
}
5238
project {
5339
name 'ForgeFlower'
5440
}
5541
}
5642

5743
jar {
58-
into('META-INF/versions/9') {
59-
from sourceSets.java9.output
60-
}
6144
manifest {
6245
attributes(
63-
'Main-Class' : 'org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler',
64-
'Multi-Release': 'true'
46+
'Main-Class' : 'org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler'
6547
)
6648
}
6749
}

gradle/wrapper/gradle-wrapper.jar

285 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ pluginManagement {
66
}
77

88
include 'ForgeFlower'
9-
include 'ForgeFlower9'
109

1110
project(':ForgeFlower').buildFileName = 'TeamCityIsAnnoying'

0 commit comments

Comments
 (0)