Skip to content

Commit a521287

Browse files
committed
Update dependencies, mainly JDT to support java 23.
1 parent 8d1c786 commit a521287

File tree

9 files changed

+76
-30
lines changed

9 files changed

+76
-30
lines changed

build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath 'org.ow2.asm:asm:9.7'
7-
classpath 'org.ow2.asm:asm-tree:9.7'
6+
classpath libs.bundles.asm
87
}
98
}
109

@@ -13,14 +12,14 @@ plugins {
1312
id 'idea'
1413
id 'eclipse'
1514
id 'maven-publish'
16-
id 'net.minecraftforge.licenser' version '1.0.1'
15+
id 'net.minecraftforge.licenser' version '1.1.0'
1716
id 'net.minecraftforge.gradleutils' version '[2.3,2.4)'
17+
id 'com.github.ben-manes.versions' version '0.52.0'
1818
}
1919

2020
group = 'net.minecraftforge'
2121
archivesBaseName = 'srg2source'
2222
version = gradleutils.tagOffsetVersion
23-
println('Version: ' + version)
2423

2524
java {
2625
toolchain.languageVersion = JavaLanguageVersion.of(17)

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ dependencyResolutionManagement {
1414
libs {
1515
// Main
1616
library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3')
17-
library('securemodules', 'net.minecraftforge:securemodules:2.2.14')
18-
library('srgutils', 'net.minecraftforge:srgutils:0.5.10')
19-
library('jimfs', 'com.google.jimfs:jimfs:1.2')
20-
library('nulls', 'org.jetbrains:annotations:23.0.0') // Got to have our null annotations!
21-
22-
library('eclipse-jdt', 'org.eclipse.jdt:org.eclipse.jdt.core:3.37.0')
23-
library('eclipse-runtime', 'org.eclipse.platform:org.eclipse.core.runtime:3.31.0')
24-
library('eclipse-resources', 'org.eclipse.platform:org.eclipse.core.resources:3.20.100')
25-
library('eclipse-jobs', 'org.eclipse.platform:org.eclipse.core.jobs:3.15.200')
26-
library('eclipse-types', 'org.eclipse.platform:org.eclipse.core.contenttype:3.9.300')
17+
library('securemodules', 'net.minecraftforge:securemodules:2.2.21')
18+
library('srgutils', 'net.minecraftforge:srgutils:0.5.11')
19+
library('nulls', 'org.jetbrains:annotations:26.0.2') // Got to have our null annotations!
20+
21+
library('eclipse-jdt', 'org.eclipse.jdt:org.eclipse.jdt.core:3.40.0')
22+
library('eclipse-runtime', 'org.eclipse.platform:org.eclipse.core.runtime:3.32.0')
23+
library('eclipse-resources', 'org.eclipse.platform:org.eclipse.core.resources:3.22.0')
24+
library('eclipse-jobs', 'org.eclipse.platform:org.eclipse.core.jobs:3.15.400')
25+
library('eclipse-types', 'org.eclipse.platform:org.eclipse.core.contenttype:3.9.600')
2726
bundle('eclipse', ['eclipse-jdt', 'eclipse-runtime', 'eclipse-resources', 'eclipse-jobs', 'eclipse-types'])
2827

2928
// Test
3029
library('ml', 'net.minecraftforge:modlauncher:10.1.4')
30+
library('jimfs', 'com.google.jimfs:jimfs:1.3.0')
3131

32-
version('junit', '5.10.1')
32+
version('junit', '5.12.0')
3333
library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
3434
library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
35-
library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.10.1')
35+
library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.12.0')
3636
bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher'])
3737

38-
version('asm', '9.7')
38+
version('asm', '9.7.1')
3939
library('asm', 'org.ow2.asm', 'asm' ).versionRef('asm')
4040
library('asm-tree', 'org.ow2.asm', 'asm-tree').versionRef('asm')
4141
bundle('asm', ['asm', 'asm-tree'])

src/main/java/net/minecraftforge/srg2source/ConsoleTool.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package net.minecraftforge.srg2source;
77

88
import java.nio.file.Files;
9-
import java.nio.file.Path;
109
import java.nio.file.Paths;
1110
import java.util.ArrayList;
1211
import java.util.Deque;
@@ -15,14 +14,10 @@
1514
import java.util.List;
1615
import java.util.Locale;
1716
import java.util.Map;
18-
import java.util.Set;
1917
import java.util.stream.Collectors;
2018

21-
import cpw.mods.modlauncher.Launcher;
22-
import cpw.mods.modlauncher.api.ServiceRunner;
2319
import net.minecraftforge.srg2source.extract.RangeExtractor;
2420
import net.minecraftforge.srg2source.util.TransformingUtil;
25-
import net.minecraftforge.srg2source.util.Util;
2621

2722
public class ConsoleTool {
2823
public static void main(String[] args) throws Exception {

src/main/java/net/minecraftforge/srg2source/api/RangeExtractorBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class RangeExtractorBuilder {
4242
private boolean fatalMixins = false;
4343
private boolean logWarnings = false;
4444
private boolean enablePreview = false;
45+
private boolean failOnError = false;
4546

4647
public RangeExtractorBuilder sourceCompatibility(SourceVersion value) {
4748
this.sourceVersion = value;
@@ -191,6 +192,11 @@ public RangeExtractorBuilder enablePreview() {
191192
return this;
192193
}
193194

195+
public RangeExtractorBuilder failOnError() {
196+
this.failOnError = true;
197+
return this;
198+
}
199+
194200
public RangeExtractor build() {
195201
RangeExtractor ret = new RangeExtractor();
196202
ret.setLogger(logStd);
@@ -216,6 +222,8 @@ public RangeExtractor build() {
216222
ret.logWarnings();
217223
if (this.enablePreview)
218224
ret.enablePreview();
225+
if (this.failOnError)
226+
ret.failOnError();
219227

220228
if (this.cache != null) {
221229
try (InputStream fin = new FileInputStream(this.cache)) {

src/main/java/net/minecraftforge/srg2source/api/SourceVersion.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public enum SourceVersion {
2424
JAVA_19(JavaCore.VERSION_19),
2525
JAVA_20(JavaCore.VERSION_20),
2626
JAVA_21(JavaCore.VERSION_21),
27+
JAVA_22(JavaCore.VERSION_22),
28+
JAVA_23(JavaCore.VERSION_23),
2729
;
2830

2931
private String spec;

src/main/java/net/minecraftforge/srg2source/extract/RangeExtractor.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.PrintWriter;
1515
import java.nio.charset.Charset;
1616
import java.nio.charset.StandardCharsets;
17+
import java.util.ArrayList;
1718
import java.util.Arrays;
1819
import java.util.HashMap;
1920
import java.util.Hashtable;
@@ -54,6 +55,7 @@ public class RangeExtractor extends ConfLogger<RangeExtractor> {
5455
private boolean fatalMixins = false;
5556
private boolean logWarnings = false;
5657
private boolean enablePreview = false;
58+
private boolean failOnError = false;
5759

5860
public RangeExtractor(){}
5961

@@ -85,6 +87,9 @@ public void logWarnings() {
8587
public void enablePreview() {
8688
this.enablePreview = true;
8789
}
90+
public void failOnError() {
91+
this.failOnError = true;
92+
}
8893

8994
public void addLibrary(File value) {
9095
String fileName = value.getPath().toLowerCase(Locale.ENGLISH);
@@ -160,11 +165,20 @@ private boolean legacyGenerate(String[] files) {
160165
parser.setUnitName(path);
161166
parser.setSource(data.toCharArray());
162167
CompilationUnit cu = (CompilationUnit)parser.createAST(null);
163-
if (cu.getProblems() != null && cu.getProblems().length > 0)
164-
Arrays.stream(cu.getProblems()).filter(p -> !p.isWarning()).forEach(p -> log(" Compile Error! " + p.toString()));
168+
if (cu.getProblems() != null && cu.getProblems().length > 0) {
169+
var errors = new ArrayList<String>();
170+
for (var p : cu.getProblems()) {
171+
if (!p.isWarning()) {
172+
errors.add(p.toString());
173+
log(" Compile Error! " + p.toString());
174+
}
175+
}
176+
if (this.failOnError && !errors.isEmpty())
177+
rethrow(new RuntimeException("Compile errors found in " + path + ": " + String.join(", ", errors)));
178+
}
165179

166180
SymbolReferenceWalker walker = new SymbolReferenceWalker(this, builder, enableMixins);
167-
walker.safeWalk(cu);
181+
rethrow(walker.safeWalk(cu));
168182
}
169183

170184
RangeMap range = builder.build();
@@ -217,7 +231,7 @@ public void acceptAST(String path, CompilationUnit cu) {
217231
Arrays.stream(cu.getProblems()).filter(p -> logWarnings || !p.isWarning()).forEach(p -> log(" Compile Error! " + p.toString()));
218232

219233
SymbolReferenceWalker walker = new SymbolReferenceWalker(RangeExtractor.this, builder, enableMixins);
220-
walker.safeWalk(cu);
234+
rethrow(walker.safeWalk(cu));
221235
}
222236

223237
RangeMap range = builder.build();
@@ -241,6 +255,12 @@ public void acceptAST(String path, CompilationUnit cu) {
241255
return true;
242256
}
243257

258+
@SuppressWarnings("unchecked")
259+
private <E extends Throwable> void rethrow(Throwable error) throws E {
260+
if (error != null && this.failOnError)
261+
throw (E)error;
262+
}
263+
244264
private void cleanup() {
245265
try {
246266
input.close();

src/main/java/net/minecraftforge/srg2source/extract/SymbolReferenceWalker.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,20 @@ private boolean process(TypeDeclaration node) {
533533
return false;
534534
}
535535

536+
/**
537+
* This is an 'Implicit' class declaration, from JEP 463.
538+
*
539+
* We use a child walker to process all class like objects, so that the walker has context of what class it is in.
540+
* This means we need to cancel processing the children and walk them ourselves in the child walker.
541+
*/
542+
private boolean process(ImplicitTypeDeclaration node) {
543+
String name = getInternalName((ITypeBinding)node.getName().resolveBinding(), node.getName());
544+
SymbolReferenceWalker walker = new SymbolReferenceWalker(this, name, null, null);
545+
walker.acceptChild(node.getJavadoc());
546+
walker.acceptChildren(node.bodyDeclarations());
547+
return false;
548+
}
549+
536550
/**
537551
* Right now we do not dump import range information.
538552
* The Applier does very rudimentary import management itself.
@@ -566,6 +580,7 @@ private boolean process(PackageDeclaration node) {
566580
* This is what causes ViewFrustum to add the extra ChunkRenderDispatcher.ChunkRender import:
567581
* `renderChunkFactory.new ChunkRender();`
568582
*/
583+
@SuppressWarnings("deprecation")
569584
private boolean process(ClassInstanceCreation node) {
570585
if (node.getExpression() == null || node.getAST().apiLevel() >= JLS3 && !node.getType().isSimpleType() || node.getAST().apiLevel() <= JLS2 && !node.getName().isSimpleName())
571586
return true;
@@ -578,13 +593,13 @@ private boolean process(ClassInstanceCreation node) {
578593
acceptChildren(node.typeArguments());
579594
name = ((SimpleType) node.getType()).getName();
580595
}
581-
596+
582597
IBinding binding = name.resolveBinding();
583598
if (binding.getKind() != IBinding.TYPE) {
584599
error(node, "Non type binding when constructing an instance: " + binding.getName());
585600
return false;
586601
}
587-
602+
588603
String clsName = getInternalName((ITypeBinding) binding, name);
589604
builder.addClassReference(name.getStartPosition(), name.getLength(), name.toString(), clsName, true);
590605
acceptChildren(node.arguments());
@@ -688,6 +703,7 @@ public ASTVisitor getVisitor() {
688703
@Override public boolean visit(CreationReference node) { return true; }
689704
@Override public boolean visit(Dimension node) { return true; }
690705
@Override public boolean visit(DoStatement node) { return true; }
706+
@Override public boolean visit(EitherOrMultiPattern node) { return true; }
691707
@Override public boolean visit(EmptyStatement node) { return true; }
692708
@Override public boolean visit(EnhancedForStatement node) { return true; }
693709
@Override public boolean visit(EnumConstantDeclaration node) { return true; }
@@ -700,13 +716,16 @@ public ASTVisitor getVisitor() {
700716
@Override public boolean visit(ForStatement node) { return true; }
701717
@Override public boolean visit(GuardedPattern node) { return true; }
702718
@Override public boolean visit(IfStatement node) { return true; }
719+
@Override public boolean visit(ImplicitTypeDeclaration node) { return process(node); }
703720
@Override public boolean visit(ImportDeclaration node) { return process(node); }
704721
@Override public boolean visit(InfixExpression node) { return true; }
705722
@Override public boolean visit(Initializer node) { return process(node); }
706723
@Override public boolean visit(InstanceofExpression node) { return true; }
707724
@Override public boolean visit(PatternInstanceofExpression node) { return true; }
708725
@Override public boolean visit(IntersectionType node) { return true; }
709726
@Override public boolean visit(Javadoc node) { return true; }
727+
@Override public boolean visit(JavaDocRegion node) { return true; }
728+
@Override public boolean visit(JavaDocTextElement node) { return true; }
710729
@Override public boolean visit(LabeledStatement node) { return process(node); }
711730
@Override public boolean visit(LambdaExpression node) { return process(node); }
712731
@Override public boolean visit(LineComment node) { return true; }
@@ -738,6 +757,7 @@ public ASTVisitor getVisitor() {
738757
@Override public boolean visit(QualifiedType node) { return true; }
739758
@Override public boolean visit(RequiresDirective node) { return true; }
740759
@Override public boolean visit(RecordDeclaration node) { return process(node); }
760+
@Override public boolean visit(RecordPattern node) { return true; }
741761
@Override public boolean visit(ReturnStatement node) { return true; }
742762
@Override public boolean visit(SimpleName node) { return process(node); }
743763
@Override public boolean visit(SimpleType node) { return true; }
@@ -753,6 +773,7 @@ public ASTVisitor getVisitor() {
753773
@Override public boolean visit(SwitchStatement node) { return true; }
754774
@Override public boolean visit(SynchronizedStatement node) { return true; }
755775
@Override public boolean visit(TagElement node) { return true; }
776+
@Override public boolean visit(TagProperty node) { return true; }
756777
@Override public boolean visit(TextBlock node) { return true; }
757778
@Override public boolean visit(TextElement node) { return true; }
758779
@Override public boolean visit(ThisExpression node) { return true; }

src/test/java/net/minecraftforge/srg2source/test/MinecraftTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class MinecraftTest {
5858
//It will make all necessary files for this test.
5959

6060
private static final Path MCP_ROOT = Paths.get("Z:/Projects/MCPConfig/");
61-
private static final String MC_VERSION = "1.20.5-rc1";
61+
private static final String MC_VERSION = "1.21.4";
6262
private static final OutputStream NULL_OUTPUT = new OutputStream() { public void write(int b) throws IOException { } };
6363

6464
/**
@@ -125,6 +125,7 @@ public long extract(boolean forceOld) throws Exception {
125125
.batch(!forceOld)
126126
.output(root.resolve("extract_" + (forceOld ? "legacy" : "batched") + ".txt"))
127127
.sourceCompatibility(SourceVersion.JAVA_21)
128+
.failOnError()
128129
.logger(log);
129130

130131
libraries.forEach(l -> {

0 commit comments

Comments
 (0)