diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java index 3aef2ced..ae0ce282 100644 --- a/src/delombok/lombok/delombok/PrettyPrinter.java +++ b/src/delombok/lombok/delombok/PrettyPrinter.java @@ -524,6 +524,12 @@ public class PrettyPrinter extends JCTree.Visitor { private Name currentTypeName; @Override public void visitClassDef(JCClassDecl tree) { + if ((tree.mods.flags & IMPLICIT_CLASS) != 0) { + printClassMembers(tree.defs, false, false); + consumeComments(endPos(tree)); + return; + } + println(); printDocComment(tree); align(); diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index f6dbc4da..08c13cc4 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -84,6 +84,7 @@ public class Javac { public static final long GENERATED_MEMBER = 1L << 24; // MethodSymbols, VarSymbols (marks methods and the constructor generated in records) 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. public static final long NON_SEALED = 1L << 63; // ClassSymbols (Flag to indicate that the class/interface was declared with the non-sealed modifier) + 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. /** * 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}. diff --git a/test/pretty/resource/after/CompactSourceFile.java b/test/pretty/resource/after/CompactSourceFile.java new file mode 100644 index 00000000..e60d5b98 --- /dev/null +++ b/test/pretty/resource/after/CompactSourceFile.java @@ -0,0 +1,3 @@ +void main() { + IO.print("This is valid java as of JDK25"); +} diff --git a/test/pretty/resource/before/CompactSourceFile.java b/test/pretty/resource/before/CompactSourceFile.java new file mode 100644 index 00000000..7c598aca --- /dev/null +++ b/test/pretty/resource/before/CompactSourceFile.java @@ -0,0 +1,5 @@ +// version 25: + +void main() { + IO.print("This is valid java as of JDK25"); +}