Skip to content

Commit

Permalink
build: Bump to a minimum requirement of Java 17 (#113)
Browse files Browse the repository at this point in the history
* build: Bump to a minimum requirement of Java 17

* Perform a patch tidy-up and basic warning pass

This removes unused imports, resolves patch ordering issues, and deals
with easily resolvable IDE warnings -- reducing noise during further
development.

We also ensure that patches are a linear progression that compiles
at each commit.
  • Loading branch information
zml2008 authored Nov 23, 2022
1 parent ee4d12c commit 40e20cf
Show file tree
Hide file tree
Showing 49 changed files with 646 additions and 1,106 deletions.
4 changes: 2 additions & 2 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ project {
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)
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)
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)
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)
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)
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)
text("docker_gradle_version", "7.5.1", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
text("env.EMAIL", "ForgeTC@MinecraftForge.net", label = "Git Email", description = "Git email for use in the fake repo", display = ParameterDisplay.HIDDEN, allowEmpty = false)
checkbox("env.GITPATCHER_ADD_GIT_SAFEDIR", "true", label = "Add submodules as safedirs (Gitpatcher)", description = "Whether to add the submodule and patched repository as safe directories for git", checked = "true", unchecked = "false")
checkbox(
Expand Down

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions FernFlower-Patches/0002-Test-Framework-upgrades.patch
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ index 4c5641fec76837a51094d4a54800d5b7475446ca..7d29c198014cbfee8092fd31461208ce
private static boolean isTestDataDir(File dir) {
return dir.isDirectory() && new File(dir, "classes").isDirectory() && new File(dir, "results").isDirectory();
diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java
index e64cf91c0674163f5c81b874e21e84da83fd264e..721a3606e209f4f803dcb6b513a5768c9c437c48 100644
index e64cf91c0674163f5c81b874e21e84da83fd264e..8c4811fe2e4c46bf87bc0b4ac7752bae5243faf1 100644
--- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java
+++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java
@@ -2,26 +2,14 @@
@@ -2,27 +2,13 @@
package org.jetbrains.java.decompiler;

import org.jetbrains.java.decompiler.main.DecompilerContext;
Expand All @@ -98,12 +98,12 @@ index e64cf91c0674163f5c81b874e21e84da83fd264e..721a3606e209f4f803dcb6b513a5768c
-
-public class SingleClassesTest {
- private DecompilerTestFixture fixture;
-
+public class SingleClassesTest extends SingleClassesTestBase {
+ protected DecompilerTestFixture fixture;

/*
* Set individual test duration time limit to 60 seconds.
@@ -30,19 +18,14 @@ public class SingleClassesTest {
* This will help us to test bugs hanging decompiler.
@@ -30,19 +16,14 @@ public class SingleClassesTest {
@Rule
public Timeout globalTimeout = Timeout.seconds(60);

Expand Down Expand Up @@ -131,7 +131,7 @@ index e64cf91c0674163f5c81b874e21e84da83fd264e..721a3606e209f4f803dcb6b513a5768c
}

@Test public void testPrimitiveNarrowing() { doTest("pkg/TestPrimitiveNarrowing"); }
@@ -226,45 +209,4 @@ public class SingleClassesTest {
@@ -226,45 +207,4 @@ public class SingleClassesTest {

@Test(expected = ClassFormatException.class)
public void testUnsupportedConstantPoolEntry() { doTest("java11/TestUnsupportedConstantPoolEntry"); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ index 804443bf66c6cc2a9cadf5ef11c44827257aaf53..a45067feeedaece4546ae2dbc5148fbf
String enclClassName = entry.outerNameIdx != 0 ? entry.enclosingName : cl.qualifiedName;
if (enclClassName == null || innerName.equals(enclClassName)) {
diff --git a/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java b/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java
index bc8992ff40bf8655077d2c01a7038bfbbfe999c0..4930acdf38046e1dfe3f04a7e68b4ff88c4ed594 100644
index bc8992ff40bf8655077d2c01a7038bfbbfe999c0..34be3854cad1675d54a32929d5e1fe1641f1a929 100644
--- a/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java
+++ b/src/org/jetbrains/java/decompiler/main/InitializerProcessor.java
@@ -13,6 +13,9 @@ import org.jetbrains.java.decompiler.modules.decompiler.stats.Statements;
Expand Down Expand Up @@ -121,10 +121,3 @@ index bc8992ff40bf8655077d2c01a7038bfbbfe999c0..4930acdf38046e1dfe3f04a7e68b4ff8
}
}
}
@@ -248,4 +295,4 @@ public final class InitializerProcessor {

return true;
}
-}
\ No newline at end of file
+}
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ index fe2d3b14c6e48dc08831123ef80902bc3126ceca..86cac9e08f0f0d3ebd43353b64eba956
}
else {
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
index f7addc6af8928ee2b2d1b9a09d13750413d4721f..79dceb558c4b99591e87d917739bcf4c66bda292 100644
index 939863351be0544adc7c4079dc2dbb18be877fb9..6216a80e20d1a1bbb80c5b343b743832e0421dbc 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
@@ -933,6 +933,7 @@ public class ExprProcessor implements CodeConstants {
@@ -932,6 +932,7 @@ public class ExprProcessor implements CodeConstants {
}

TextBuffer buf = new TextBuffer();
Expand All @@ -203,14 +203,14 @@ index f7addc6af8928ee2b2d1b9a09d13750413d4721f..79dceb558c4b99591e87d917739bcf4c
for (Exprent expr : lst) {
if (buf.length() > 0 && expr.type == Exprent.EXPRENT_VAR && ((VarExprent)expr).isClassDef()) {
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java
index 13d747a5ec6b961763f70b9174efeaf976336dbc..5428c1d1b10e0fbaa7c3b62725acd34d0632f37c 100644
index 13d747a5ec6b961763f70b9174efeaf976336dbc..ad41b185d8c830f26b4f598a6568b3272a11d86f 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java
@@ -480,10 +480,17 @@ public class FinallyProcessor {
// so remove dummy exit
startBlocks.remove(graph.getLast());
startBlocks.removeAll(tryBlocks);
+ List<BasicBlock> starts = new ArrayList<BasicBlock>(startBlocks);
+ List<BasicBlock> starts = new ArrayList<>(startBlocks);
+ Collections.sort(starts, new Comparator<BasicBlock>() {
+ @Override
+ public int compare(BasicBlock o1, BasicBlock o2) {
Expand All @@ -229,7 +229,7 @@ index 13d747a5ec6b961763f70b9174efeaf976336dbc..5428c1d1b10e0fbaa7c3b62725acd34d
// DotExporter.toDotFile(graph, new File("c:\\Temp\\fern5.dot"), true);
// } catch(Exception ex){ex.printStackTrace();}

+ List<Entry<BasicBlock, Boolean>> lasts = new ArrayList<Entry<BasicBlock, Boolean>>(mapLast.entrySet());
+ List<Entry<BasicBlock, Boolean>> lasts = new ArrayList<>(mapLast.entrySet());
+ // We must sort here to prevent decompile differences deriving from hash maps.
+ Collections.sort(lasts, new Comparator<Entry<BasicBlock, Boolean>>() {
+ @Override
Expand Down Expand Up @@ -338,10 +338,10 @@ index 82ae0a25a20d2727f611d359e699d6666d1e0ae4..a86f0d2887c6c19cb1d911ec43830eb6

return res;
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java
index 3882cfd68af7f55938311363a69a2dded3fffbab..48d38ff8657fd6d237fe2d75677d89b8bbd8852d 100644
index a7033f507fd9667d773977803718c08810f0d750..3edae784f56848a5697879cfef9e05130ee38d34 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java
@@ -220,7 +220,7 @@ public class ConstExprent extends Exprent {
@@ -219,7 +219,7 @@ public class ConstExprent extends Exprent {
else if (floatVal == Float.NEGATIVE_INFINITY) {
return new TextBuffer("-1.0F / 0.0F");
}
Expand All @@ -350,7 +350,7 @@ index 3882cfd68af7f55938311363a69a2dded3fffbab..48d38ff8657fd6d237fe2d75677d89b8

case CodeConstants.TYPE_DOUBLE:
double doubleVal = (Double)value;
@@ -251,15 +251,15 @@ public class ConstExprent extends Exprent {
@@ -250,15 +250,15 @@ public class ConstExprent extends Exprent {
}
}
else if (Double.isNaN(doubleVal)) {
Expand All @@ -370,7 +370,7 @@ index 3882cfd68af7f55938311363a69a2dded3fffbab..48d38ff8657fd6d237fe2d75677d89b8

case CodeConstants.TYPE_NULL:
return new TextBuffer("null");
@@ -277,6 +277,18 @@ public class ConstExprent extends Exprent {
@@ -276,6 +276,18 @@ public class ConstExprent extends Exprent {

throw new RuntimeException("invalid constant type: " + constType);
}
Expand All @@ -390,7 +390,7 @@ index 3882cfd68af7f55938311363a69a2dded3fffbab..48d38ff8657fd6d237fe2d75677d89b8
private boolean inConstantVariable(String classSignature, String variableName) {
ClassesProcessor.ClassNode node = (ClassesProcessor.ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE);
diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java
index cc1f537e71af0748b7b97d7d8489198e2a677cc9..0994d9466eda95b46d3f234bf977e8e9aa0e0899 100644
index cc1f537e71af0748b7b97d7d8489198e2a677cc9..9b1b3de632a63bbba1f5f7a99d5f75bf537bd171 100644
--- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java
+++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java
@@ -15,7 +15,10 @@ import org.jetbrains.java.decompiler.struct.match.MatchEngine;
Expand All @@ -404,15 +404,16 @@ index cc1f537e71af0748b7b97d7d8489198e2a677cc9..0994d9466eda95b46d3f234bf977e8e9
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
@@ -131,6 +134,38 @@ public class Exprent implements IMatchable {
@@ -131,6 +134,39 @@ public class Exprent implements IMatchable {
}
}

+ public static List<? extends Exprent> sortIndexed(List<? extends Exprent> lst) {
+ List<Exprent> ret = new ArrayList<Exprent>();
+ List<VarExprent> defs = new ArrayList<VarExprent>();
+ List<Exprent> ret = new ArrayList<>();
+ List<VarExprent> defs = new ArrayList<>();
+
+ Comparator<VarExprent> comp = new Comparator<VarExprent>() {
+ Comparator<VarExprent> comp = new Comparator<>() {
+ @Override
+ public int compare(VarExprent o1, VarExprent o2) {
+ return o1.getIndex() - o2.getIndex();
+ }
Expand All @@ -439,7 +440,7 @@ index cc1f537e71af0748b7b97d7d8489198e2a677cc9..0994d9466eda95b46d3f234bf977e8e9
+ }
+ return ret;
+ }
+
+
// *****************************************************************************
// IMatchable implementation
// *****************************************************************************
Expand Down
Loading

0 comments on commit 40e20cf

Please sign in to comment.