Skip to content

Commit 6648115

Browse files
committed
Merge branch 'jdk25'
2 parents 94b01e4 + 39ef5d0 commit 6648115

File tree

10 files changed

+82
-52
lines changed

10 files changed

+82
-52
lines changed

.github/workflows/ant.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
runs-on: ubuntu-24.04
4242
needs: build
4343
env:
44-
EA_JDK: 24
44+
EA_JDK: 25
4545
strategy:
4646
matrix:
47-
jdk: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
47+
jdk: [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
4848
goal: [javacCurrent]
4949
include:
5050
- jdk: 11

buildScripts/tests.ant.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,33 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
140140
</sequential>
141141
</macrodef>
142142

143+
<!-- 11 is LTS -->
143144
<target name="test.javac11" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using javac11 as underlying compiler">
144145
<test.javacX version="11" />
145146
</target>
146147

148+
<!-- 17 is LTS -->
147149
<target name="test.javac17" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using javac17 as underlying compiler">
148150
<test.javacX version="17" />
149151
</target>
150152

153+
<!-- 21 is LTS -->
151154
<target name="test.javac21" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using javac21 as underlying compiler">
152155
<test.javacX version="21" />
153156
</target>
154157

155158
<!-- For non-LTS versions, feel free to aggressively update these to the current non-LTS openjdk version, and delete them once they roll out of the 6 month window. -->
156159

160+
<!-- 24 is non-LTS, but the current release -->
157161
<target name="test.javac24" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using javac24 as underlying compiler">
158162
<test.javacX version="24" />
159163
</target>
160164

165+
<!-- 25 is LTS -->
166+
<target name="test.javac25" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using javac25 as underlying compiler">
167+
<test.javacX version="25" />
168+
</target>
169+
161170
<target name="test.javacCurrent" depends="test.compile, test.formatter.compile" description="runs the tests on your default VM, using its javac as underlying compiler">
162171
<echo>Running TestJavac on JVM${ant.java.version}, with the javac built into your VM distributon.</echo>
163172
<junit haltonfailure="yes" fork="true" forkmode="once">
@@ -337,5 +346,5 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
337346
</target>
338347

339348
<target name="test" depends="test.javacCurrent, test.eclipse-202503" description="runs the tests against the default JVM, javac, and eclipse" />
340-
<target name="test.broad" depends="test.javac8, test.javac17, test.javac21, test.javac24, test.eclipse-oxygen, test.eclipse-202503, test.eclipse-202006-jdk8" description="runs the tests against the default JVM, javac, and eclipse" />
349+
<target name="test.broad" depends="test.javac8, test.javac17, test.javac21, test.javac24, test.javac25, test.eclipse-oxygen, test.eclipse-202503, test.eclipse-202006-jdk8" description="runs the tests against the default JVM, javac, and eclipse" />
341350
</project>

buildScripts/vm-finder.ant.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ and rerun the build; this build is capable of finding VMs automatically on many
6262
<local name="java_home.result" />
6363
<exec newenvironment="true" executable="${exe.java_home}" errorproperty="discard" outputproperty="java_home.answer" failifexecutionfails="false" resultproperty="java_home.result">
6464
<env key="floobargle" value="FOO" /> <!-- we do not want JAVA_HOME to be set. This requires newenvironment="true" AND some sort of env value -->
65-
<arg value="-v" />
65+
<arg value="-Fv" />
6666
<arg value="${find-vm.version}" />
6767
</exec>
6868
<condition property="jvm.loc" value="${java_home.answer}">

src/core/lombok/javac/JavacAST.java

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2009-2020 The Project Lombok Authors.
2+
* Copyright (C) 2009-2025 The Project Lombok Authors.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -41,6 +41,7 @@
4141
import lombok.core.CleanupTask;
4242
import lombok.permit.Permit;
4343

44+
import com.sun.tools.javac.code.Lint.LintCategory;
4445
import com.sun.tools.javac.code.Source;
4546
import com.sun.tools.javac.code.Symtab;
4647
import com.sun.tools.javac.model.JavacElements;
@@ -415,7 +416,6 @@ private static void initJcAnnotatedType(Class<?> context) {
415416
JCANNOTATEDTYPE_FIELDS_INITIALIZED = true;
416417
}
417418

418-
419419
private static Field JCENHANCEDFORLOOP_VARORRECORDPATTERN_FIELD = Permit.permissiveGetField(JCEnhancedForLoop.class, "varOrRecordPattern");
420420
private static JCTree getVarOrRecordPattern(JCEnhancedForLoop loop) {
421421
if (JCENHANCEDFORLOOP_VARORRECORDPATTERN_FIELD == null) {
@@ -581,9 +581,6 @@ void printMessage(Diagnostic.Kind kind, String message, JavacNode node, Diagnost
581581
case ERROR:
582582
errorLogger.error(pos, message);
583583
break;
584-
case MANDATORY_WARNING:
585-
errorLogger.mandatoryWarning(pos, message);
586-
break;
587584
case WARNING:
588585
errorLogger.warning(pos, message);
589586
break;
@@ -596,7 +593,7 @@ void printMessage(Diagnostic.Kind kind, String message, JavacNode node, Diagnost
596593
if (newSource != null) errorLogger.useSource(oldSource);
597594
}
598595
}
599-
596+
600597
public void removeFromDeferredDiagnostics(int startPos, int endPos) {
601598
JCCompilationUnit self = (JCCompilationUnit) top().get();
602599
new CompilerMessageSuppressor(getContext()).removeAllBetween(self.sourcefile, startPos, endPos);
@@ -643,29 +640,23 @@ private ErrorLog(Log log, Messager messager, Field errorCount, Field warningCoun
643640
this.errorCount = errorCount;
644641
this.warningCount = warningCount;
645642
}
646-
643+
647644
final JavaFileObject useSource(JavaFileObject file) {
648645
return log.useSource(file);
649646
}
650-
647+
651648
final void error(DiagnosticPosition pos, String message) {
652649
increment(errorCount);
653650
error1(pos, message);
654651
}
655-
652+
656653
final void warning(DiagnosticPosition pos, String message) {
657654
increment(warningCount);
658655
warning1(pos, message);
659656
}
660-
661-
final void mandatoryWarning(DiagnosticPosition pos, String message) {
662-
increment(warningCount);
663-
mandatoryWarning1(pos, message);
664-
}
665-
657+
666658
abstract void error1(DiagnosticPosition pos, String message);
667659
abstract void warning1(DiagnosticPosition pos, String message);
668-
abstract void mandatoryWarning1(DiagnosticPosition pos, String message);
669660
abstract void note(DiagnosticPosition pos, String message);
670661

671662
private void increment(Field field) {
@@ -689,7 +680,6 @@ static ErrorLog create(Messager messager, Context context) {
689680
for (Field field : log.getClass().getFields()) {
690681
if (field.getName().equals("multipleErrors")) {
691682
hasMultipleErrors = true;
692-
break;
693683
}
694684
}
695685
if (hasMultipleErrors) return new JdkBefore9(log, messager, errorCount);
@@ -708,7 +698,7 @@ static class JdkBefore9 extends ErrorLog {
708698
private JdkBefore9(Log log, Messager messager, Field errorCount) {
709699
super(log, messager, errorCount, null);
710700
}
711-
701+
712702
@Override void error1(DiagnosticPosition pos, String message) {
713703
boolean prev = log.multipleErrors;
714704
log.multipleErrors = true;
@@ -718,15 +708,11 @@ private JdkBefore9(Log log, Messager messager, Field errorCount) {
718708
log.multipleErrors = prev;
719709
}
720710
}
721-
711+
722712
@Override void warning1(DiagnosticPosition pos, String message) {
723713
log.warning(pos, "proc.messager", message);
724714
}
725-
726-
@Override void mandatoryWarning1(DiagnosticPosition pos, String message) {
727-
log.mandatoryWarning(pos, "proc.messager", message);
728-
}
729-
715+
730716
@Override void note(DiagnosticPosition pos, String message) {
731717
log.note(pos, "proc.messager", message);
732718
}
@@ -735,36 +721,38 @@ private JdkBefore9(Log log, Messager messager, Field errorCount) {
735721
static class Jdk9Plus extends ErrorLog {
736722
private static final String PROC_MESSAGER = "proc.messager";
737723
private Object multiple;
738-
private Method errorMethod, warningMethod, mandatoryWarningMethod, noteMethod;
724+
private Method errorMethod, warningMethod, noteMethod;
739725
private Method errorKey, warningKey, noteKey;
740726
private JCDiagnostic.Factory diags;
741727

742728
private Jdk9Plus(Log log, Messager messager, Field errorCount, Field warningCount) {
743729
super(log, messager, errorCount, warningCount);
744-
730+
745731
try {
746732
final String jcd = "com.sun.tools.javac.util.JCDiagnostic";
747733
Class<?> df = Class.forName(jcd + "$DiagnosticFlag");
748734
for (Object constant : df.getEnumConstants()) {
749735
if (constant.toString().equals("MULTIPLE")) this.multiple = constant;
750736
}
751-
737+
752738
Class<?> errorCls = Class.forName(jcd + "$Error");
753739
Class<?> warningCls = Class.forName(jcd + "$Warning");
754740
Class<?> noteCls = Class.forName(jcd + "$Note");
755741

756742
Class<?> lc = log.getClass();
757743
this.errorMethod = Permit.getMethod(lc, "error", df, DiagnosticPosition.class, errorCls);
758744
this.warningMethod = Permit.getMethod(lc, "warning", DiagnosticPosition.class, warningCls);
759-
this.mandatoryWarningMethod = Permit.getMethod(lc, "mandatoryWarning", DiagnosticPosition.class, warningCls);
760745
this.noteMethod = Permit.getMethod(lc, "note", DiagnosticPosition.class, noteCls);
761-
746+
762747
Field diagsField = Permit.getField(lc.getSuperclass(), "diags");
763748
this.diags = (JCDiagnostic.Factory) diagsField.get(log);
764-
749+
765750
Class<?> dc = this.diags.getClass();
766751
this.errorKey = Permit.getMethod(dc, "errorKey", String.class, Object[].class);
767-
this.warningKey = Permit.getMethod(dc, "warningKey", String.class, Object[].class);
752+
this.warningKey = Permit.permissiveGetMethod(dc, "warningKey", String.class, Object[].class);
753+
if (warningKey == null) {
754+
this.warningKey = Permit.getMethod(dc, "warningKey", LintCategory.class, String.class, Object[].class);
755+
}
768756
this.noteKey = Permit.getMethod(dc, "noteKey", String.class, Object[].class);
769757
} catch (Throwable t) {
770758
//t.printStackTrace();
@@ -775,19 +763,18 @@ private Jdk9Plus(Log log, Messager messager, Field errorCount, Field warningCoun
775763
Object error = Permit.invokeSneaky(this.errorKey, diags, PROC_MESSAGER, new Object[] { message });
776764
if (error != null) Permit.invokeSneaky(errorMethod, log, multiple, pos, error);
777765
}
778-
766+
779767
@Override
780768
void warning1(DiagnosticPosition pos, String message) {
781-
Object warning = Permit.invokeSneaky(this.warningKey, diags, PROC_MESSAGER, new Object[] { message });
769+
Object warning;
770+
if (this.warningKey.getParameterTypes().length == 3) {
771+
warning = Permit.invokeSneaky(this.warningKey, diags, null, PROC_MESSAGER, new Object[] { message });
772+
} else {
773+
warning = Permit.invokeSneaky(this.warningKey, diags, PROC_MESSAGER, new Object[] { message });
774+
}
782775
if (warning != null) Permit.invokeSneaky(warningMethod, log, pos, warning);
783776
}
784-
785-
@Override
786-
void mandatoryWarning1(DiagnosticPosition pos, String message) {
787-
Object warning = Permit.invokeSneaky(this.warningKey, diags, PROC_MESSAGER, new Object[] { message });
788-
if (warning != null) Permit.invokeSneaky(mandatoryWarningMethod, log, pos, warning);
789-
}
790-
777+
791778
@Override
792779
void note(DiagnosticPosition pos, String message) {
793780
Object note = Permit.invokeSneaky(this.noteKey, diags, PROC_MESSAGER, new Object[] { message });

src/delombok/lombok/delombok/PrettyPrinter.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2016-2024 The Project Lombok Authors.
2+
* Copyright (C) 2016-2025 The Project Lombok Authors.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -92,13 +92,13 @@
9292
import com.sun.tools.javac.util.Position;
9393

9494
import lombok.javac.CommentInfo;
95-
import lombok.javac.Javac;
96-
import lombok.javac.PackageName;
97-
import lombok.permit.Permit;
9895
import lombok.javac.CommentInfo.EndConnection;
9996
import lombok.javac.CommentInfo.StartConnection;
97+
import lombok.javac.Javac;
10098
import lombok.javac.JavacTreeMaker.TreeTag;
10199
import lombok.javac.JavacTreeMaker.TypeTag;
100+
import lombok.javac.PackageName;
101+
import lombok.permit.Permit;
102102

103103
public class PrettyPrinter extends JCTree.Visitor {
104104
private static final String LINE_SEP = System.getProperty("line.separator");
@@ -514,8 +514,22 @@ private Name name_value(Name someName) {
514514
println(";", tree);
515515
}
516516

517+
void printModuleImport(JCTree tree) {
518+
JCExpression qualid = readObject(tree, "module", null);
519+
520+
aPrint("import module ");
521+
print(qualid);
522+
println(";", tree);
523+
}
524+
517525
private Name currentTypeName;
518526
@Override public void visitClassDef(JCClassDecl tree) {
527+
if ((tree.mods.flags & IMPLICIT_CLASS) != 0) {
528+
printClassMembers(tree.defs, false, false);
529+
consumeComments(endPos(tree));
530+
return;
531+
}
532+
519533
println();
520534
printDocComment(tree);
521535
align();
@@ -697,7 +711,7 @@ private void printVarDef0(JCVariableDecl tree) {
697711
*/
698712
try {
699713
innermostArrayBracketsAreVarargs = varargs;
700-
if (tree.vartype == null || tree.vartype.pos == -1) {
714+
if (tree.vartype == null || tree.vartype.pos == -1 || endPos(tree.vartype) == -1) {
701715
print("var");
702716
} else {
703717
print(tree.vartype);
@@ -1033,7 +1047,7 @@ private void printModifierKeywords(JCModifiers tree) {
10331047
if ((v & NATIVE) != 0) print("native ");
10341048
if ((v & ABSTRACT) != 0) print("abstract ");
10351049
if ((v & SEALED) != 0) print("sealed ");
1036-
if ((v & NON_SEALED) != 0) print("non-sealed ");
1050+
if ((v & NON_SEALED) != 0) print("non-sealed "); // Yes, this is a real keyword.
10371051
if ((v & STRICTFP) != 0) print("strictfp ");
10381052
if ((v & DEFAULT) != 0 && (v & INTERFACE) == 0) print("default ");
10391053
}
@@ -1710,6 +1724,8 @@ public void visitTypeBoundKind(TypeBoundKind tree) {
17101724
printRecordPattern(tree);
17111725
} else if (className.endsWith("$JCAnyPattern")) { // Introduced in JDK22
17121726
print("_");
1727+
} else if (className.endsWith("$JCModuleImport")) { // Introduced in JDK25
1728+
printModuleImport(tree);
17131729
} else {
17141730
throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree);
17151731
}

src/utils/lombok/javac/Javac.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ private Javac() {
7777

7878
private static final AtomicInteger compilerVersion = new AtomicInteger(-1);
7979

80-
/* This section includes flags that would ordinarily be in Flags, but which are 'too new' (we don't compile against older versions of javac for compatibility). */
80+
/* This section includes flags that would ordinarily be in com.sun.tools.javac.code.Flags, but which are 'too new' (we don't compile against older versions of javac for compatibility). */
8181
public static final long RECORD = 1L << 61; // ClassSymbols, MethodSymbols, VarSymbols (Marks types as being records, as well as the 'fields' in the compact declaration, and the canonical constructor)
8282
public static final long COMPACT_RECORD_CONSTRUCTOR = 1L << 51; // MethodSymbols (the 'implicit' many-args constructor that records have)
8383
public static final long UNINITIALIZED_FIELD = 1L << 51; // VarSymbols (To identify fields that the compact record constructor won't initialize)
8484
public static final long GENERATED_MEMBER = 1L << 24; // MethodSymbols, VarSymbols (marks methods and the constructor generated in records)
85-
public static final long SEALED = 1L << 62; // ClassSymbols (Flag to indicate sealed class/interface declaration)
85+
public static final long SEALED = 1L << 62 | 1L << 48; // ClassSymbols (Flag to indicate sealed class/interface declaration) - from the introduction of sealed until ~jdk23, this was 62. In jdk24, it's 48. Ugh.
8686
public static final long NON_SEALED = 1L << 63; // ClassSymbols (Flag to indicate that the class/interface was declared with the non-sealed modifier)
87+
public static final long IMPLICIT_CLASS = 1L << 19; // ClassSymbols (Flag to indicate that the class/interface wasn't actually written out; it is an implicitly declared top-level class). Introduced in JDK25, JEP512.
8788

8889
/**
8990
* Returns the version of this java compiler, i.e. the JDK that it shipped in. For example, for javac v1.7, this returns {@code 7}.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
void main() {
2+
IO.print("This is valid java as of JDK25");
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import module java.base;
2+
3+
public class ModuleImport {
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// version 25:
2+
3+
void main() {
4+
IO.print("This is valid java as of JDK25");
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// version 25:
2+
3+
import module java.base;
4+
5+
public class ModuleImport {}

0 commit comments

Comments
 (0)